org.signal.zkgroup.auth.AuthCredentialPresentation Maven / Gradle / Ivy
//
// Copyright (C) 2020 Signal Messenger, LLC.
// All rights reserved.
//
// SPDX-License-Identifier: GPL-3.0-only
//
// Generated by zkgroup/codegen/codegen.py - do not edit
package org.signal.zkgroup.auth;
import java.nio.ByteBuffer;
import org.signal.zkgroup.InvalidInputException;
import org.signal.zkgroup.ZkGroupError;
import org.signal.zkgroup.groups.UuidCiphertext;
import org.signal.zkgroup.internal.ByteArray;
import org.signal.zkgroup.internal.Native;
public final class AuthCredentialPresentation extends ByteArray {
public static final int SIZE = 620;
public AuthCredentialPresentation(byte[] contents) throws InvalidInputException {
super(contents, SIZE);
int ffi_return = Native.authCredentialPresentationCheckValidContentsJNI(contents);
if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) {
throw new InvalidInputException("FFI_RETURN_INPUT_ERROR");
}
if (ffi_return != Native.FFI_RETURN_OK) {
throw new ZkGroupError("FFI_RETURN!=OK");
}
}
public UuidCiphertext getUuidCiphertext() {
byte[] newContents = new byte[UuidCiphertext.SIZE];
int ffi_return = Native.authCredentialPresentationGetUuidCiphertextJNI(contents, newContents);
if (ffi_return != Native.FFI_RETURN_OK) {
throw new ZkGroupError("FFI_RETURN!=OK");
}
try {
return new UuidCiphertext(newContents);
} catch (InvalidInputException e) {
throw new AssertionError(e);
}
}
public int getRedemptionTime() {
byte[] newContents = new byte[4];
int ffi_return = Native.authCredentialPresentationGetRedemptionTimeJNI(contents, newContents);
if (ffi_return != Native.FFI_RETURN_OK) {
throw new ZkGroupError("FFI_RETURN!=OK");
}
return ByteBuffer.wrap(newContents).getInt();
}
public byte[] serialize() {
return contents.clone();
}
}