diff --git a/uniffi/output-frameworks/anoncreds-jvm/src/main/uniffi/anoncreds/anoncreds.kt b/uniffi/output-frameworks/anoncreds-jvm/src/main/uniffi/anoncreds/anoncreds.kt index ab4ed833..f1ae45b9 100644 --- a/uniffi/output-frameworks/anoncreds-jvm/src/main/uniffi/anoncreds/anoncreds.kt +++ b/uniffi/output-frameworks/anoncreds-jvm/src/main/uniffi/anoncreds/anoncreds.kt @@ -18,12 +18,15 @@ package uniffi.anoncreds; // helpers directly inline like we're doing here. import com.sun.jna.Library +import com.sun.jna.IntegerType import com.sun.jna.Native import com.sun.jna.Pointer import com.sun.jna.Structure -import com.sun.jna.ptr.ByReference +import com.sun.jna.Callback +import com.sun.jna.ptr.* import java.nio.ByteBuffer import java.nio.ByteOrder +import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicLong @@ -37,12 +40,12 @@ open class RustBuffer : Structure() { @JvmField var len: Int = 0 @JvmField var data: Pointer? = null - class ByValue : RustBuffer(), Structure.ByValue - class ByReference : RustBuffer(), Structure.ByReference + class ByValue: RustBuffer(), Structure.ByValue + class ByReference: RustBuffer(), Structure.ByReference companion object { internal fun alloc(size: Int = 0) = rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_rustbuffer_alloc(size, status).also { + _UniFFILib.INSTANCE.ffi_anoncreds_rustbuffer_alloc(size, status).also { if(it.data == null) { throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})") } @@ -50,7 +53,7 @@ open class RustBuffer : Structure() { } internal fun free(buf: RustBuffer.ByValue) = rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_rustbuffer_free(buf, status) + _UniFFILib.INSTANCE.ffi_anoncreds_rustbuffer_free(buf, status) } } @@ -78,6 +81,19 @@ class RustBufferByReference : ByReference(16) { pointer.setInt(4, value.len) pointer.setPointer(8, value.data) } + + /** + * Get a `RustBuffer.ByValue` from this reference. + */ + fun getValue(): RustBuffer.ByValue { + val pointer = getPointer() + val value = RustBuffer.ByValue() + value.writeField("capacity", pointer.getInt(0)) + value.writeField("len", pointer.getInt(4)) + value.writeField("data", pointer.getPointer(8)) + + return value + } } // This is a helper for safely passing byte references into the rust code. @@ -169,19 +185,21 @@ public interface FfiConverterRustBuffer: FfiConverter { private inline fun rustCallWithError(errorHandler: CallStatusErrorHandler, callback: (RustCallStatus) -> U): U { var status = RustCallStatus(); val return_value = callback(status) + checkCallStatus(errorHandler, status) + return return_value +} + +// Check RustCallStatus and throw an error if the call wasn't successful +private fun checkCallStatus(errorHandler: CallStatusErrorHandler, status: RustCallStatus) { if (status.isSuccess()) { - return return_value + return } else if (status.isError()) { throw errorHandler.lift(status.error_buf) } else if (status.isPanic()) { @@ -231,6 +255,86 @@ private inline fun rustCall(callback: (RustCallStatus) -> U): U { return rustCallWithError(NullCallStatusErrorHandler, callback); } +// IntegerType that matches Rust's `usize` / C's `size_t` +public class USize(value: Long = 0) : IntegerType(Native.SIZE_T_SIZE, value, true) { + // This is needed to fill in the gaps of IntegerType's implementation of Number for Kotlin. + override fun toByte() = toInt().toByte() + override fun toChar() = toInt().toChar() + override fun toShort() = toInt().toShort() + + fun writeToBuffer(buf: ByteBuffer) { + // Make sure we always write usize integers using native byte-order, since they may be + // casted to pointer values + buf.order(ByteOrder.nativeOrder()) + try { + when (Native.SIZE_T_SIZE) { + 4 -> buf.putInt(toInt()) + 8 -> buf.putLong(toLong()) + else -> throw RuntimeException("Invalid SIZE_T_SIZE: ${Native.SIZE_T_SIZE}") + } + } finally { + buf.order(ByteOrder.BIG_ENDIAN) + } + } + + companion object { + val size: Int + get() = Native.SIZE_T_SIZE + + fun readFromBuffer(buf: ByteBuffer) : USize { + // Make sure we always read usize integers using native byte-order, since they may be + // casted from pointer values + buf.order(ByteOrder.nativeOrder()) + try { + return when (Native.SIZE_T_SIZE) { + 4 -> USize(buf.getInt().toLong()) + 8 -> USize(buf.getLong()) + else -> throw RuntimeException("Invalid SIZE_T_SIZE: ${Native.SIZE_T_SIZE}") + } + } finally { + buf.order(ByteOrder.BIG_ENDIAN) + } + } + } +} + + +// Map handles to objects +// +// This is used when the Rust code expects an opaque pointer to represent some foreign object. +// Normally we would pass a pointer to the object, but JNA doesn't support getting a pointer from an +// object reference , nor does it support leaking a reference to Rust. +// +// Instead, this class maps USize values to objects so that we can pass a pointer-sized type to +// Rust when it needs an opaque pointer. +// +// TODO: refactor callbacks to use this class +internal class UniFfiHandleMap { + private val map = ConcurrentHashMap() + // Use AtomicInteger for our counter, since we may be on a 32-bit system. 4 billion possible + // values seems like enough. If somehow we generate 4 billion handles, then this will wrap + // around back to zero and we can assume the first handle generated will have been dropped by + // then. + private val counter = java.util.concurrent.atomic.AtomicInteger(0) + + val size: Int + get() = map.size + + fun insert(obj: T): USize { + val handle = USize(counter.getAndAdd(1).toLong()) + map.put(handle, obj) + return handle + } + + fun get(handle: USize): T? { + return map.get(handle) + } + + fun remove(handle: USize) { + map.remove(handle) + } +} + // Contains loading, initialization code, // and the FFI Function declarations in a com.sun.jna.Library. @Synchronized @@ -255,365 +359,608 @@ internal interface _UniFFILib : Library { companion object { internal val INSTANCE: _UniFFILib by lazy { loadIndirect<_UniFFILib>(componentName = "anoncreds") - + .also { lib: _UniFFILib -> + uniffiCheckContractApiVersion(lib) + uniffiCheckApiChecksums(lib) + } } } - fun ffi_anoncreds_d8c0_LinkSecret_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_linksecret(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_LinkSecret_new( - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_linksecret_new(_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_LinkSecret_new_from_json(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_linksecret_new_from_value(`valueString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_LinkSecret_get_big_number(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_linksecret_get_big_number(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_LinkSecret_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_linksecret_get_value(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_Nonce_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_nonce(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_Nonce_new( - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_nonce_new(_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Nonce_new_from_value(`valueString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_nonce_new_from_value(`valueString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Nonce_get_value(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_nonce_get_value(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_CredentialDefinition_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_credentialdefinition(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_CredentialDefinition_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_credentialdefinition_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_CredentialDefinition_get_schema_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialdefinition_get_schema_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialDefinition_get_signature_type(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialdefinition_get_signature_type(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialDefinition_get_tag(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialdefinition_get_tag(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialDefinition_get_issuer_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialdefinition_get_issuer_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialDefinition_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialdefinition_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_CredentialOffer_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_credentialoffer(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_CredentialOffer_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_credentialoffer_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_CredentialOffer_get_schema_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialoffer_get_schema_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialOffer_get_cred_def_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialoffer_get_cred_def_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialOffer_get_key_correctness_proof(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialoffer_get_key_correctness_proof(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialOffer_get_nonce(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialoffer_get_nonce(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_CredentialOffer_get_method_name(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialoffer_get_method_name(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialOffer_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialoffer_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_CredentialRequest_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_credentialrequest(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_CredentialRequest_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_credentialrequest_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_CredentialRequest_get_blinded_credential_secrets_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialrequest_get_blinded_credential_secrets_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialRequest_get_blinded_credential_secrets_correctness_proof_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialrequest_get_blinded_credential_secrets_correctness_proof_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_CredentialRequest_get_nonce(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialrequest_get_nonce(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_CredentialRequest_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialrequest_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_CredentialKeyCorrectnessProof_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_credentialkeycorrectnessproof(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_CredentialKeyCorrectnessProof_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_credentialkeycorrectnessproof_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_CredentialKeyCorrectnessProof_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialkeycorrectnessproof_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_RevocationRegistryDefinition_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_revocationregistrydefinition(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_RevocationRegistryDefinition_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_revocationregistrydefinition_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_RevocationRegistryDefinition_get_issuer_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinition_get_issuer_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_RevocationRegistryDefinition_get_tag(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinition_get_tag(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_RevocationRegistryDefinition_get_cred_def_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinition_get_cred_def_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_RevocationRegistryDefinition_get_value(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinition_get_value(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_RevocationRegistryDefinition_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinition_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_RevocationRegistryDefinitionPrivate_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_revocationregistrydefinitionprivate(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_RevocationRegistryDefinitionPrivate_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_revocationregistrydefinitionprivate_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_RevocationRegistryDefinitionPrivate_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinitionprivate_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_Credential_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_credential(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_Credential_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_credential_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Credential_get_schema_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_schema_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Credential_get_cred_def_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_cred_def_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Credential_get_rev_reg_id(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_rev_reg_id(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Credential_get_values(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_values(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Credential_get_signature_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_signature_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Credential_get_signature_correctness_proof_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_signature_correctness_proof_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Credential_get_rev_reg_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_rev_reg_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Credential_get_witness_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_witness_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Credential_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credential_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_RevocationStatusList_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_revocationstatuslist(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_RevocationStatusList_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_revocationstatuslist_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_RevocationStatusList_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationstatuslist_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_RevocationRegistryDefinitionValue_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_revocationregistrydefinitionvalue(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_RevocationRegistryDefinitionValue_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_revocationregistrydefinitionvalue_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_RevocationRegistryDefinitionValue_get_max_cred_num(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinitionvalue_get_max_cred_num(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Int - - fun anoncreds_d8c0_RevocationRegistryDefinitionValue_get_tails_hash(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinitionvalue_get_tails_hash(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_RevocationRegistryDefinitionValue_get_tails_location(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinitionvalue_get_tails_location(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_RevocationRegistryDefinitionValue_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinitionvalue_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_RevocationRegistryDefinitionValuePublicKeys_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_revocationregistrydefinitionvaluepublickeys(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_RevocationRegistryDefinitionValuePublicKeys_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_revocationregistrydefinitionvaluepublickeys_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_RevocationRegistryDefinitionValuePublicKeys_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_revocationregistrydefinitionvaluepublickeys_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_CredentialDefinitionPrivate_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_credentialdefinitionprivate(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_CredentialDefinitionPrivate_new(`jsonString`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_credentialdefinitionprivate_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_CredentialDefinitionPrivate_get_json(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_credentialdefinitionprivate_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_Issuer_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_issuer(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_Issuer_new( - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_issuer_new(_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Issuer_create_schema(`ptr`: Pointer,`schemaName`: RustBuffer.ByValue,`schemaVersion`: RustBuffer.ByValue,`issuerId`: RustBuffer.ByValue,`attrNames`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_issuer_create_schema(`ptr`: Pointer,`schemaName`: RustBuffer.ByValue,`schemaVersion`: RustBuffer.ByValue,`issuerId`: RustBuffer.ByValue,`attrNames`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Issuer_create_credential_definition(`ptr`: Pointer,`schemaId`: RustBuffer.ByValue,`schema`: RustBuffer.ByValue,`issuerId`: RustBuffer.ByValue,`tag`: RustBuffer.ByValue,`signatureType`: RustBuffer.ByValue,`config`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_issuer_create_credential_definition(`ptr`: Pointer,`schemaId`: RustBuffer.ByValue,`schema`: RustBuffer.ByValue,`issuerId`: RustBuffer.ByValue,`tag`: RustBuffer.ByValue,`signatureType`: RustBuffer.ByValue,`config`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Issuer_create_revocation_registry_def(`ptr`: Pointer,`credDef`: Pointer,`credDefId`: RustBuffer.ByValue,`issuerId`: RustBuffer.ByValue,`tag`: RustBuffer.ByValue,`revRegType`: RustBuffer.ByValue,`maxCredNum`: Int, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_issuer_create_revocation_registry_def(`ptr`: Pointer,`credDef`: Pointer,`credDefId`: RustBuffer.ByValue,`issuerId`: RustBuffer.ByValue,`tag`: RustBuffer.ByValue,`revRegType`: RustBuffer.ByValue,`maxCredNum`: Int,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Issuer_create_revocation_status_list(`ptr`: Pointer,`revRegDefId`: RustBuffer.ByValue,`revRegDef`: Pointer,`issuerId`: RustBuffer.ByValue,`timestamp`: RustBuffer.ByValue,`issuanceByDefault`: Byte, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_issuer_create_revocation_status_list(`ptr`: Pointer,`revRegDefId`: RustBuffer.ByValue,`revRegDef`: Pointer,`issuerId`: RustBuffer.ByValue,`timestamp`: RustBuffer.ByValue,`issuanceByDefault`: Byte,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Issuer_update_revocation_status_list_timestamp_only(`ptr`: Pointer,`timestamp`: Long,`currentList`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_issuer_update_revocation_status_list_timestamp_only(`ptr`: Pointer,`timestamp`: Long,`currentList`: Pointer,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Issuer_update_revocation_status_list(`ptr`: Pointer,`timestamp`: RustBuffer.ByValue,`issued`: RustBuffer.ByValue,`revoked`: RustBuffer.ByValue,`revRegDef`: Pointer,`currentList`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_issuer_update_revocation_status_list(`ptr`: Pointer,`timestamp`: RustBuffer.ByValue,`issued`: RustBuffer.ByValue,`revoked`: RustBuffer.ByValue,`revRegDef`: Pointer,`currentList`: Pointer,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Issuer_create_credential_offer(`ptr`: Pointer,`schemaId`: RustBuffer.ByValue,`credDefId`: RustBuffer.ByValue,`correctnessProof`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_issuer_create_credential_offer(`ptr`: Pointer,`schemaId`: RustBuffer.ByValue,`credDefId`: RustBuffer.ByValue,`correctnessProof`: Pointer,_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Issuer_create_credential(`ptr`: Pointer,`credDef`: Pointer,`credDefPrivate`: Pointer,`credOffer`: Pointer,`credRequest`: Pointer,`credValues`: RustBuffer.ByValue,`revRegId`: RustBuffer.ByValue,`revStatusList`: RustBuffer.ByValue,`revocationConfig`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_issuer_create_credential(`ptr`: Pointer,`credDef`: Pointer,`credDefPrivate`: Pointer,`credOffer`: Pointer,`credRequest`: Pointer,`credValues`: RustBuffer.ByValue,`revRegId`: RustBuffer.ByValue,`revStatusList`: RustBuffer.ByValue,`revocationConfig`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun ffi_anoncreds_d8c0_Prover_object_free(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_prover(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_Prover_new( - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_prover_new(_uniffi_out_err: RustCallStatus, ): Pointer - - fun anoncreds_d8c0_Prover_create_credential_request(`ptr`: Pointer,`entropy`: RustBuffer.ByValue,`proverDid`: RustBuffer.ByValue,`credDef`: Pointer,`linkSecret`: Pointer,`linkSecretId`: RustBuffer.ByValue,`credentialOffer`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_prover_create_credential_request(`ptr`: Pointer,`entropy`: RustBuffer.ByValue,`proverDid`: RustBuffer.ByValue,`credDef`: Pointer,`linkSecret`: Pointer,`linkSecretId`: RustBuffer.ByValue,`credentialOffer`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun anoncreds_d8c0_Prover_process_credential(`ptr`: Pointer,`credential`: Pointer,`credRequestMetadata`: RustBuffer.ByValue,`linkSecret`: Pointer,`credDef`: Pointer,`revRegDef`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_prover_process_credential(`ptr`: Pointer,`credential`: Pointer,`credRequestMetadata`: RustBuffer.ByValue,`linkSecret`: Pointer,`credDef`: Pointer,`revRegDef`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Unit - - fun anoncreds_d8c0_Prover_create_link_secret(`ptr`: Pointer, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_prover_create_presentation(`ptr`: Pointer,`presentationRequest`: Pointer,`credentials`: RustBuffer.ByValue,`selfAttested`: RustBuffer.ByValue,`linkSecret`: Pointer,`schemas`: RustBuffer.ByValue,`credentialDefinitions`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): Pointer - - fun ffi_anoncreds_d8c0_rustbuffer_alloc(`size`: Int, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_method_prover_create_link_secret(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, + ): Pointer + fun uniffi_anoncreds_fn_free_presentation(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, + ): Unit + fun uniffi_anoncreds_fn_constructor_presentation_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, + ): Pointer + fun uniffi_anoncreds_fn_method_presentation_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_presentationrequest(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, + ): Unit + fun uniffi_anoncreds_fn_constructor_presentationrequest_new(`jsonString`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, + ): Pointer + fun uniffi_anoncreds_fn_method_presentationrequest_get_json(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - - fun ffi_anoncreds_d8c0_rustbuffer_free(`buf`: RustBuffer.ByValue, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_free_verifier(`ptr`: Pointer,_uniffi_out_err: RustCallStatus, ): Unit - - fun ffi_anoncreds_d8c0_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Int, - _uniffi_out_err: RustCallStatus + fun uniffi_anoncreds_fn_constructor_verifier_new(_uniffi_out_err: RustCallStatus, + ): Pointer + fun uniffi_anoncreds_fn_method_verifier_verify_presentation(`ptr`: Pointer,`presentation`: Pointer,`presentationRequest`: Pointer,`schemas`: RustBuffer.ByValue,`credentialDefinitions`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, + ): Byte + fun ffi_anoncreds_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - + fun ffi_anoncreds_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus, + ): RustBuffer.ByValue + fun ffi_anoncreds_rustbuffer_free(`buf`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, + ): Unit + fun ffi_anoncreds_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Int,_uniffi_out_err: RustCallStatus, + ): RustBuffer.ByValue + fun uniffi__checksum_method_linksecret_get_big_number( + ): Short + fun uniffi__checksum_method_linksecret_get_value( + ): Short + fun uniffi__checksum_method_nonce_get_value( + ): Short + fun uniffi__checksum_method_credentialdefinition_get_schema_id( + ): Short + fun uniffi__checksum_method_credentialdefinition_get_signature_type( + ): Short + fun uniffi__checksum_method_credentialdefinition_get_tag( + ): Short + fun uniffi__checksum_method_credentialdefinition_get_issuer_id( + ): Short + fun uniffi__checksum_method_credentialdefinition_get_json( + ): Short + fun uniffi__checksum_method_credentialoffer_get_schema_id( + ): Short + fun uniffi__checksum_method_credentialoffer_get_cred_def_id( + ): Short + fun uniffi__checksum_method_credentialoffer_get_key_correctness_proof( + ): Short + fun uniffi__checksum_method_credentialoffer_get_nonce( + ): Short + fun uniffi__checksum_method_credentialoffer_get_method_name( + ): Short + fun uniffi__checksum_method_credentialoffer_get_json( + ): Short + fun uniffi__checksum_method_credentialrequest_get_blinded_credential_secrets_json( + ): Short + fun uniffi__checksum_method_credentialrequest_get_blinded_credential_secrets_correctness_proof_json( + ): Short + fun uniffi__checksum_method_credentialrequest_get_nonce( + ): Short + fun uniffi__checksum_method_credentialrequest_get_json( + ): Short + fun uniffi__checksum_method_credentialkeycorrectnessproof_get_json( + ): Short + fun uniffi__checksum_method_revocationregistrydefinition_get_issuer_id( + ): Short + fun uniffi__checksum_method_revocationregistrydefinition_get_tag( + ): Short + fun uniffi__checksum_method_revocationregistrydefinition_get_cred_def_id( + ): Short + fun uniffi__checksum_method_revocationregistrydefinition_get_value( + ): Short + fun uniffi__checksum_method_revocationregistrydefinition_get_json( + ): Short + fun uniffi__checksum_method_revocationregistrydefinitionprivate_get_json( + ): Short + fun uniffi__checksum_method_credential_get_schema_id( + ): Short + fun uniffi__checksum_method_credential_get_cred_def_id( + ): Short + fun uniffi__checksum_method_credential_get_rev_reg_id( + ): Short + fun uniffi__checksum_method_credential_get_values( + ): Short + fun uniffi__checksum_method_credential_get_signature_json( + ): Short + fun uniffi__checksum_method_credential_get_signature_correctness_proof_json( + ): Short + fun uniffi__checksum_method_credential_get_rev_reg_json( + ): Short + fun uniffi__checksum_method_credential_get_witness_json( + ): Short + fun uniffi__checksum_method_credential_get_json( + ): Short + fun uniffi__checksum_method_revocationstatuslist_get_json( + ): Short + fun uniffi__checksum_method_revocationregistrydefinitionvalue_get_max_cred_num( + ): Short + fun uniffi__checksum_method_revocationregistrydefinitionvalue_get_tails_hash( + ): Short + fun uniffi__checksum_method_revocationregistrydefinitionvalue_get_tails_location( + ): Short + fun uniffi__checksum_method_revocationregistrydefinitionvalue_get_json( + ): Short + fun uniffi__checksum_method_revocationregistrydefinitionvaluepublickeys_get_json( + ): Short + fun uniffi__checksum_method_credentialdefinitionprivate_get_json( + ): Short + fun uniffi__checksum_method_issuer_create_schema( + ): Short + fun uniffi__checksum_method_issuer_create_credential_definition( + ): Short + fun uniffi__checksum_method_issuer_create_revocation_registry_def( + ): Short + fun uniffi__checksum_method_issuer_create_revocation_status_list( + ): Short + fun uniffi__checksum_method_issuer_update_revocation_status_list_timestamp_only( + ): Short + fun uniffi__checksum_method_issuer_update_revocation_status_list( + ): Short + fun uniffi__checksum_method_issuer_create_credential_offer( + ): Short + fun uniffi__checksum_method_issuer_create_credential( + ): Short + fun uniffi__checksum_method_prover_create_credential_request( + ): Short + fun uniffi__checksum_method_prover_process_credential( + ): Short + fun uniffi__checksum_method_prover_create_presentation( + ): Short + fun uniffi__checksum_method_prover_create_link_secret( + ): Short + fun uniffi__checksum_method_presentation_get_json( + ): Short + fun uniffi__checksum_method_presentationrequest_get_json( + ): Short + fun uniffi__checksum_method_verifier_verify_presentation( + ): Short + fun uniffi__checksum_constructor_linksecret_new( + ): Short + fun uniffi__checksum_constructor_linksecret_new_from_value( + ): Short + fun uniffi__checksum_constructor_nonce_new( + ): Short + fun uniffi__checksum_constructor_nonce_new_from_value( + ): Short + fun uniffi__checksum_constructor_credentialdefinition_new( + ): Short + fun uniffi__checksum_constructor_credentialoffer_new( + ): Short + fun uniffi__checksum_constructor_credentialrequest_new( + ): Short + fun uniffi__checksum_constructor_credentialkeycorrectnessproof_new( + ): Short + fun uniffi__checksum_constructor_revocationregistrydefinition_new( + ): Short + fun uniffi__checksum_constructor_revocationregistrydefinitionprivate_new( + ): Short + fun uniffi__checksum_constructor_credential_new( + ): Short + fun uniffi__checksum_constructor_revocationstatuslist_new( + ): Short + fun uniffi__checksum_constructor_revocationregistrydefinitionvalue_new( + ): Short + fun uniffi__checksum_constructor_revocationregistrydefinitionvaluepublickeys_new( + ): Short + fun uniffi__checksum_constructor_credentialdefinitionprivate_new( + ): Short + fun uniffi__checksum_constructor_issuer_new( + ): Short + fun uniffi__checksum_constructor_prover_new( + ): Short + fun uniffi__checksum_constructor_presentation_new( + ): Short + fun uniffi__checksum_constructor_presentationrequest_new( + ): Short + fun uniffi__checksum_constructor_verifier_new( + ): Short + fun ffi_anoncreds_uniffi_contract_version( + ): Int } +private fun uniffiCheckContractApiVersion(lib: _UniFFILib) { + // Get the bindings contract version from our ComponentInterface + val bindings_contract_version = 22 + // Get the scaffolding contract version by calling the into the dylib + val scaffolding_contract_version = lib.ffi_anoncreds_uniffi_contract_version() + if (bindings_contract_version != scaffolding_contract_version) { + throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project") + } +} + +@Suppress("UNUSED_PARAMETER") +private fun uniffiCheckApiChecksums(lib: _UniFFILib) { + if (lib.uniffi__checksum_method_linksecret_get_big_number() != 17566.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_linksecret_get_value() != 31184.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_nonce_get_value() != 55559.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialdefinition_get_schema_id() != 2873.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialdefinition_get_signature_type() != 33283.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialdefinition_get_tag() != 64489.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialdefinition_get_issuer_id() != 19453.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialdefinition_get_json() != 13633.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialoffer_get_schema_id() != 9785.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialoffer_get_cred_def_id() != 54789.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialoffer_get_key_correctness_proof() != 4524.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialoffer_get_nonce() != 8992.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialoffer_get_method_name() != 10089.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialoffer_get_json() != 21450.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialrequest_get_blinded_credential_secrets_json() != 28369.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialrequest_get_blinded_credential_secrets_correctness_proof_json() != 6360.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialrequest_get_nonce() != 29424.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialrequest_get_json() != 26067.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialkeycorrectnessproof_get_json() != 28526.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinition_get_issuer_id() != 55636.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinition_get_tag() != 9407.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinition_get_cred_def_id() != 18370.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinition_get_value() != 54233.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinition_get_json() != 30273.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinitionprivate_get_json() != 49890.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_schema_id() != 5900.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_cred_def_id() != 17534.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_rev_reg_id() != 62977.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_values() != 54784.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_signature_json() != 23915.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_signature_correctness_proof_json() != 52780.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_rev_reg_json() != 55518.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_witness_json() != 40173.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credential_get_json() != 19925.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationstatuslist_get_json() != 26059.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinitionvalue_get_max_cred_num() != 22553.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinitionvalue_get_tails_hash() != 52751.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinitionvalue_get_tails_location() != 10552.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinitionvalue_get_json() != 27094.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_revocationregistrydefinitionvaluepublickeys_get_json() != 2321.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_credentialdefinitionprivate_get_json() != 8321.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_issuer_create_schema() != 16570.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_issuer_create_credential_definition() != 13296.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_issuer_create_revocation_registry_def() != 29924.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_issuer_create_revocation_status_list() != 18299.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_issuer_update_revocation_status_list_timestamp_only() != 37725.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_issuer_update_revocation_status_list() != 64292.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_issuer_create_credential_offer() != 26660.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_issuer_create_credential() != 5649.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_prover_create_credential_request() != 26116.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_prover_process_credential() != 64866.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_prover_create_presentation() != 47751.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_prover_create_link_secret() != 11469.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_presentation_get_json() != 57516.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_presentationrequest_get_json() != 64699.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_method_verifier_verify_presentation() != 42012.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_linksecret_new() != 27344.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_linksecret_new_from_value() != 34527.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_nonce_new() != 62144.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_nonce_new_from_value() != 17009.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_credentialdefinition_new() != 21273.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_credentialoffer_new() != 61941.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_credentialrequest_new() != 16217.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_credentialkeycorrectnessproof_new() != 30790.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_revocationregistrydefinition_new() != 35203.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_revocationregistrydefinitionprivate_new() != 17035.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_credential_new() != 21829.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_revocationstatuslist_new() != 41592.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_revocationregistrydefinitionvalue_new() != 15419.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_revocationregistrydefinitionvaluepublickeys_new() != 46152.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_credentialdefinitionprivate_new() != 27360.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_issuer_new() != 52382.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_prover_new() != 45439.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_presentation_new() != 56164.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_presentationrequest_new() != 11986.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi__checksum_constructor_verifier_new() != 16505.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} + // Public interface members begin here. @@ -878,7 +1225,7 @@ abstract class FFIObject( try { return block(this.pointer) } finally { - // This decrement aways matches the increment we performed above. + // This decrement always matches the increment we performed above. if (this.callCounter.decrementAndGet() == 0L) { this.freeRustArcPtr() } @@ -889,24 +1236,14 @@ abstract class FFIObject( public interface CredentialInterface { fun `getSchemaId`(): SchemaId - fun `getCredDefId`(): CredentialDefinitionId - fun `getRevRegId`(): RevocationRegistryId? - fun `getValues`(): CredentialValues - fun `getSignatureJson`(): String - fun `getSignatureCorrectnessProofJson`(): String - fun `getRevRegJson`(): String? - - fun `getWitnessJson`(): String? - - @Throws(AnoncredsException::class) + fun `getWitnessJson`(): String?@Throws(AnoncredsException::class) fun `getJson`(): String - } class Credential( @@ -915,7 +1252,7 @@ class Credential( constructor(`jsonString`: String) : this( rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_credential_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -928,84 +1265,111 @@ class Credential( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_Credential_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_credential(this.pointer, status) } } override fun `getSchemaId`(): SchemaId = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_schema_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_schema_id(it, + + _status) } }.let { FfiConverterTypeSchemaId.lift(it) } + override fun `getCredDefId`(): CredentialDefinitionId = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_cred_def_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_cred_def_id(it, + + _status) } }.let { FfiConverterTypeCredentialDefinitionId.lift(it) } + override fun `getRevRegId`(): RevocationRegistryId? = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_rev_reg_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_rev_reg_id(it, + + _status) } }.let { FfiConverterOptionalTypeRevocationRegistryId.lift(it) } + override fun `getValues`(): CredentialValues = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_values(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_values(it, + + _status) } }.let { FfiConverterTypeCredentialValues.lift(it) } + override fun `getSignatureJson`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_signature_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_signature_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + override fun `getSignatureCorrectnessProofJson`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_signature_correctness_proof_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_signature_correctness_proof_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + override fun `getRevRegJson`(): String? = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_rev_reg_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_rev_reg_json(it, + + _status) } }.let { FfiConverterOptionalString.lift(it) } + override fun `getWitnessJson`(): String? = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_witness_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_witness_json(it, + + _status) } }.let { FfiConverterOptionalString.lift(it) } + @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Credential_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credential_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -1038,16 +1402,10 @@ public object FfiConverterTypeCredential: FfiConverter { public interface CredentialDefinitionInterface { fun `getSchemaId`(): SchemaId - fun `getSignatureType`(): SignatureType - fun `getTag`(): String - - fun `getIssuerId`(): IssuerId - - @Throws(AnoncredsException::class) + fun `getIssuerId`(): IssuerId@Throws(AnoncredsException::class) fun `getJson`(): String - } class CredentialDefinition( @@ -1056,7 +1414,7 @@ class CredentialDefinition( constructor(`jsonString`: String) : this( rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialDefinition_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_credentialdefinition_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -1069,52 +1427,67 @@ class CredentialDefinition( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_CredentialDefinition_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_credentialdefinition(this.pointer, status) } } override fun `getSchemaId`(): SchemaId = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialDefinition_get_schema_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialdefinition_get_schema_id(it, + + _status) } }.let { FfiConverterTypeSchemaId.lift(it) } + override fun `getSignatureType`(): SignatureType = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialDefinition_get_signature_type(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialdefinition_get_signature_type(it, + + _status) } }.let { FfiConverterTypeSignatureType.lift(it) } + override fun `getTag`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialDefinition_get_tag(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialdefinition_get_tag(it, + + _status) } }.let { FfiConverterString.lift(it) } + override fun `getIssuerId`(): IssuerId = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialDefinition_get_issuer_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialdefinition_get_issuer_id(it, + + _status) } }.let { FfiConverterTypeIssuerId.lift(it) } + @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialDefinition_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialdefinition_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -1145,10 +1518,8 @@ public object FfiConverterTypeCredentialDefinition: FfiConverter - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialDefinitionPrivate_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_credentialdefinitionprivate_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -1170,7 +1541,7 @@ class CredentialDefinitionPrivate( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_CredentialDefinitionPrivate_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_credentialdefinitionprivate(this.pointer, status) } } @@ -1178,12 +1549,15 @@ class CredentialDefinitionPrivate( @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialDefinitionPrivate_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialdefinitionprivate_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -1214,10 +1588,8 @@ public object FfiConverterTypeCredentialDefinitionPrivate: FfiConverter - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialKeyCorrectnessProof_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_credentialkeycorrectnessproof_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -1239,7 +1611,7 @@ class CredentialKeyCorrectnessProof( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_CredentialKeyCorrectnessProof_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_credentialkeycorrectnessproof(this.pointer, status) } } @@ -1247,12 +1619,15 @@ class CredentialKeyCorrectnessProof( @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialKeyCorrectnessProof_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialkeycorrectnessproof_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -1285,18 +1660,11 @@ public object FfiConverterTypeCredentialKeyCorrectnessProof: FfiConverter - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialOffer_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_credentialoffer_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -1318,60 +1686,78 @@ class CredentialOffer( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_CredentialOffer_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_credentialoffer(this.pointer, status) } } override fun `getSchemaId`(): SchemaId = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialOffer_get_schema_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialoffer_get_schema_id(it, + + _status) } }.let { FfiConverterTypeSchemaId.lift(it) } + override fun `getCredDefId`(): CredentialDefinitionId = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialOffer_get_cred_def_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialoffer_get_cred_def_id(it, + + _status) } }.let { FfiConverterTypeCredentialDefinitionId.lift(it) } + override fun `getKeyCorrectnessProof`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialOffer_get_key_correctness_proof(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialoffer_get_key_correctness_proof(it, + + _status) } }.let { FfiConverterString.lift(it) } + override fun `getNonce`(): Nonce = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialOffer_get_nonce(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialoffer_get_nonce(it, + + _status) } }.let { FfiConverterTypeNonce.lift(it) } + override fun `getMethodName`(): String? = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialOffer_get_method_name(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialoffer_get_method_name(it, + + _status) } }.let { FfiConverterOptionalString.lift(it) } + @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialOffer_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialoffer_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -1404,14 +1790,9 @@ public object FfiConverterTypeCredentialOffer: FfiConverter - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialRequest_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_credentialrequest_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -1433,44 +1814,56 @@ class CredentialRequest( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_CredentialRequest_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_credentialrequest(this.pointer, status) } } override fun `getBlindedCredentialSecretsJson`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialRequest_get_blinded_credential_secrets_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialrequest_get_blinded_credential_secrets_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + override fun `getBlindedCredentialSecretsCorrectnessProofJson`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialRequest_get_blinded_credential_secrets_correctness_proof_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialrequest_get_blinded_credential_secrets_correctness_proof_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + override fun `getNonce`(): Nonce = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialRequest_get_nonce(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialrequest_get_nonce(it, + + _status) } }.let { FfiConverterTypeNonce.lift(it) } + @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_CredentialRequest_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_credentialrequest_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -1501,30 +1894,15 @@ public object FfiConverterTypeCredentialRequest: FfiConverter): Schema - - @Throws(AnoncredsException::class) - fun `createCredentialDefinition`(`schemaId`: String, `schema`: Schema, `issuerId`: String, `tag`: String, `signatureType`: SignatureType, `config`: CredentialDefinitionConfig): IssuerCreateCredentialDefinitionReturn - - @Throws(AnoncredsException::class) - fun `createRevocationRegistryDef`(`credDef`: CredentialDefinition, `credDefId`: String, `issuerId`: String, `tag`: String, `revRegType`: RegistryType, `maxCredNum`: UInt): IssuerCreateRevocationRegistryDefReturn - @Throws(AnoncredsException::class) + fun `createSchema`(`schemaName`: String, `schemaVersion`: String, `issuerId`: String, `attrNames`: List): Schema@Throws(AnoncredsException::class) + fun `createCredentialDefinition`(`schemaId`: String, `schema`: Schema, `issuerId`: String, `tag`: String, `signatureType`: SignatureType, `config`: CredentialDefinitionConfig): IssuerCreateCredentialDefinitionReturn@Throws(AnoncredsException::class) + fun `createRevocationRegistryDef`(`credDef`: CredentialDefinition, `credDefId`: String, `issuerId`: String, `tag`: String, `revRegType`: RegistryType, `maxCredNum`: UInt): IssuerCreateRevocationRegistryDefReturn@Throws(AnoncredsException::class) fun `createRevocationStatusList`(`revRegDefId`: String, `revRegDef`: RevocationRegistryDefinition, `issuerId`: String, `timestamp`: ULong?, `issuanceByDefault`: Boolean): RevocationStatusList - - fun `updateRevocationStatusListTimestampOnly`(`timestamp`: ULong, `currentList`: RevocationStatusList): RevocationStatusList - - @Throws(AnoncredsException::class) - fun `updateRevocationStatusList`(`timestamp`: ULong?, `issued`: List?, `revoked`: List?, `revRegDef`: RevocationRegistryDefinition, `currentList`: RevocationStatusList): RevocationStatusList - - @Throws(AnoncredsException::class) - fun `createCredentialOffer`(`schemaId`: String, `credDefId`: String, `correctnessProof`: CredentialKeyCorrectnessProof): CredentialOffer - - @Throws(AnoncredsException::class) + fun `updateRevocationStatusListTimestampOnly`(`timestamp`: ULong, `currentList`: RevocationStatusList): RevocationStatusList@Throws(AnoncredsException::class) + fun `updateRevocationStatusList`(`timestamp`: ULong?, `issued`: List?, `revoked`: List?, `revRegDef`: RevocationRegistryDefinition, `currentList`: RevocationStatusList): RevocationStatusList@Throws(AnoncredsException::class) + fun `createCredentialOffer`(`schemaId`: String, `credDefId`: String, `correctnessProof`: CredentialKeyCorrectnessProof): CredentialOffer@Throws(AnoncredsException::class) fun `createCredential`(`credDef`: CredentialDefinition, `credDefPrivate`: CredentialDefinitionPrivate, `credOffer`: CredentialOffer, `credRequest`: CredentialRequest, `credValues`: List, `revRegId`: RevocationRegistryId?, `revStatusList`: RevocationStatusList?, `revocationConfig`: CredentialRevocationConfig?): Credential - } class Issuer( @@ -1533,7 +1911,7 @@ class Issuer( constructor() : this( rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_new( _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_issuer_new(_status) }) /** @@ -1546,7 +1924,7 @@ class Issuer( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_Issuer_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_issuer(this.pointer, status) } } @@ -1554,74 +1932,98 @@ class Issuer( @Throws(AnoncredsException::class)override fun `createSchema`(`schemaName`: String, `schemaVersion`: String, `issuerId`: String, `attrNames`: List): Schema = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_create_schema(it, FfiConverterString.lower(`schemaName`), FfiConverterString.lower(`schemaVersion`), FfiConverterString.lower(`issuerId`), FfiConverterSequenceString.lower(`attrNames`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_issuer_create_schema(it, + FfiConverterString.lower(`schemaName`),FfiConverterString.lower(`schemaVersion`),FfiConverterString.lower(`issuerId`),FfiConverterSequenceString.lower(`attrNames`), + _status) } }.let { FfiConverterTypeSchema.lift(it) } + @Throws(AnoncredsException::class)override fun `createCredentialDefinition`(`schemaId`: String, `schema`: Schema, `issuerId`: String, `tag`: String, `signatureType`: SignatureType, `config`: CredentialDefinitionConfig): IssuerCreateCredentialDefinitionReturn = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_create_credential_definition(it, FfiConverterString.lower(`schemaId`), FfiConverterTypeSchema.lower(`schema`), FfiConverterString.lower(`issuerId`), FfiConverterString.lower(`tag`), FfiConverterTypeSignatureType.lower(`signatureType`), FfiConverterTypeCredentialDefinitionConfig.lower(`config`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_issuer_create_credential_definition(it, + FfiConverterString.lower(`schemaId`),FfiConverterTypeSchema.lower(`schema`),FfiConverterString.lower(`issuerId`),FfiConverterString.lower(`tag`),FfiConverterTypeSignatureType.lower(`signatureType`),FfiConverterTypeCredentialDefinitionConfig.lower(`config`), + _status) } }.let { FfiConverterTypeIssuerCreateCredentialDefinitionReturn.lift(it) } + @Throws(AnoncredsException::class)override fun `createRevocationRegistryDef`(`credDef`: CredentialDefinition, `credDefId`: String, `issuerId`: String, `tag`: String, `revRegType`: RegistryType, `maxCredNum`: UInt): IssuerCreateRevocationRegistryDefReturn = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_create_revocation_registry_def(it, FfiConverterTypeCredentialDefinition.lower(`credDef`), FfiConverterString.lower(`credDefId`), FfiConverterString.lower(`issuerId`), FfiConverterString.lower(`tag`), FfiConverterTypeRegistryType.lower(`revRegType`), FfiConverterUInt.lower(`maxCredNum`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_issuer_create_revocation_registry_def(it, + FfiConverterTypeCredentialDefinition.lower(`credDef`),FfiConverterString.lower(`credDefId`),FfiConverterString.lower(`issuerId`),FfiConverterString.lower(`tag`),FfiConverterTypeRegistryType.lower(`revRegType`),FfiConverterUInt.lower(`maxCredNum`), + _status) } }.let { FfiConverterTypeIssuerCreateRevocationRegistryDefReturn.lift(it) } + @Throws(AnoncredsException::class)override fun `createRevocationStatusList`(`revRegDefId`: String, `revRegDef`: RevocationRegistryDefinition, `issuerId`: String, `timestamp`: ULong?, `issuanceByDefault`: Boolean): RevocationStatusList = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_create_revocation_status_list(it, FfiConverterString.lower(`revRegDefId`), FfiConverterTypeRevocationRegistryDefinition.lower(`revRegDef`), FfiConverterString.lower(`issuerId`), FfiConverterOptionalULong.lower(`timestamp`), FfiConverterBoolean.lower(`issuanceByDefault`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_issuer_create_revocation_status_list(it, + FfiConverterString.lower(`revRegDefId`),FfiConverterTypeRevocationRegistryDefinition.lower(`revRegDef`),FfiConverterString.lower(`issuerId`),FfiConverterOptionalULong.lower(`timestamp`),FfiConverterBoolean.lower(`issuanceByDefault`), + _status) } }.let { FfiConverterTypeRevocationStatusList.lift(it) } + override fun `updateRevocationStatusListTimestampOnly`(`timestamp`: ULong, `currentList`: RevocationStatusList): RevocationStatusList = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_update_revocation_status_list_timestamp_only(it, FfiConverterULong.lower(`timestamp`), FfiConverterTypeRevocationStatusList.lower(`currentList`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_issuer_update_revocation_status_list_timestamp_only(it, + FfiConverterULong.lower(`timestamp`),FfiConverterTypeRevocationStatusList.lower(`currentList`), + _status) } }.let { FfiConverterTypeRevocationStatusList.lift(it) } + @Throws(AnoncredsException::class)override fun `updateRevocationStatusList`(`timestamp`: ULong?, `issued`: List?, `revoked`: List?, `revRegDef`: RevocationRegistryDefinition, `currentList`: RevocationStatusList): RevocationStatusList = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_update_revocation_status_list(it, FfiConverterOptionalULong.lower(`timestamp`), FfiConverterOptionalSequenceUInt.lower(`issued`), FfiConverterOptionalSequenceUInt.lower(`revoked`), FfiConverterTypeRevocationRegistryDefinition.lower(`revRegDef`), FfiConverterTypeRevocationStatusList.lower(`currentList`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_issuer_update_revocation_status_list(it, + FfiConverterOptionalULong.lower(`timestamp`),FfiConverterOptionalSequenceUInt.lower(`issued`),FfiConverterOptionalSequenceUInt.lower(`revoked`),FfiConverterTypeRevocationRegistryDefinition.lower(`revRegDef`),FfiConverterTypeRevocationStatusList.lower(`currentList`), + _status) } }.let { FfiConverterTypeRevocationStatusList.lift(it) } + @Throws(AnoncredsException::class)override fun `createCredentialOffer`(`schemaId`: String, `credDefId`: String, `correctnessProof`: CredentialKeyCorrectnessProof): CredentialOffer = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_create_credential_offer(it, FfiConverterString.lower(`schemaId`), FfiConverterString.lower(`credDefId`), FfiConverterTypeCredentialKeyCorrectnessProof.lower(`correctnessProof`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_issuer_create_credential_offer(it, + FfiConverterString.lower(`schemaId`),FfiConverterString.lower(`credDefId`),FfiConverterTypeCredentialKeyCorrectnessProof.lower(`correctnessProof`), + _status) } }.let { FfiConverterTypeCredentialOffer.lift(it) } + @Throws(AnoncredsException::class)override fun `createCredential`(`credDef`: CredentialDefinition, `credDefPrivate`: CredentialDefinitionPrivate, `credOffer`: CredentialOffer, `credRequest`: CredentialRequest, `credValues`: List, `revRegId`: RevocationRegistryId?, `revStatusList`: RevocationStatusList?, `revocationConfig`: CredentialRevocationConfig?): Credential = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Issuer_create_credential(it, FfiConverterTypeCredentialDefinition.lower(`credDef`), FfiConverterTypeCredentialDefinitionPrivate.lower(`credDefPrivate`), FfiConverterTypeCredentialOffer.lower(`credOffer`), FfiConverterTypeCredentialRequest.lower(`credRequest`), FfiConverterSequenceTypeAttributeValues.lower(`credValues`), FfiConverterOptionalTypeRevocationRegistryId.lower(`revRegId`), FfiConverterOptionalTypeRevocationStatusList.lower(`revStatusList`), FfiConverterOptionalTypeCredentialRevocationConfig.lower(`revocationConfig`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_issuer_create_credential(it, + FfiConverterTypeCredentialDefinition.lower(`credDef`),FfiConverterTypeCredentialDefinitionPrivate.lower(`credDefPrivate`),FfiConverterTypeCredentialOffer.lower(`credOffer`),FfiConverterTypeCredentialRequest.lower(`credRequest`),FfiConverterSequenceTypeAttributeValues.lower(`credValues`),FfiConverterOptionalTypeRevocationRegistryId.lower(`revRegId`),FfiConverterOptionalTypeRevocationStatusList.lower(`revStatusList`),FfiConverterOptionalTypeCredentialRevocationConfig.lower(`revocationConfig`), + _status) } }.let { FfiConverterTypeCredential.lift(it) } + } @@ -1653,11 +2055,8 @@ public object FfiConverterTypeIssuer: FfiConverter { public interface LinkSecretInterface { - fun `getBigNumber`(): String - - @Throws(AnoncredsException::class) - fun `getJson`(): String - + fun `getBigNumber`(): String@Throws(AnoncredsException::class) + fun `getValue`(): String } class LinkSecret( @@ -1666,7 +2065,7 @@ class LinkSecret( constructor() : this( rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_LinkSecret_new( _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_linksecret_new(_status) }) /** @@ -1679,34 +2078,40 @@ class LinkSecret( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_LinkSecret_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_linksecret(this.pointer, status) } } override fun `getBigNumber`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_LinkSecret_get_big_number(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_linksecret_get_big_number(it, + + _status) } }.let { FfiConverterString.lift(it) } - @Throws(AnoncredsException::class)override fun `getJson`(): String = + + @Throws(AnoncredsException::class)override fun `getValue`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_LinkSecret_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_linksecret_get_value(it, + + _status) } }.let { FfiConverterString.lift(it) } + companion object { - fun `newFromJson`(`jsonString`: String): LinkSecret = + fun `newFromValue`(`valueString`: String): LinkSecret = LinkSecret( rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_LinkSecret_new_from_json(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_linksecret_new_from_value(FfiConverterString.lower(`valueString`),_status) }) } @@ -1739,10 +2144,8 @@ public object FfiConverterTypeLinkSecret: FfiConverter { public interface NonceInterface { - @Throws(AnoncredsException::class) fun `getValue`(): String - } class Nonce( @@ -1751,7 +2154,7 @@ class Nonce( constructor() : this( rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Nonce_new( _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_nonce_new(_status) }) /** @@ -1764,7 +2167,7 @@ class Nonce( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_Nonce_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_nonce(this.pointer, status) } } @@ -1772,18 +2175,21 @@ class Nonce( @Throws(AnoncredsException::class)override fun `getValue`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Nonce_get_value(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_nonce_get_value(it, + + _status) } }.let { FfiConverterString.lift(it) } + companion object { fun `newFromValue`(`valueString`: String): Nonce = Nonce( rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Nonce_new_from_value(FfiConverterString.lower(`valueString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_nonce_new_from_value(FfiConverterString.lower(`valueString`),_status) }) } @@ -1815,16 +2221,152 @@ public object FfiConverterTypeNonce: FfiConverter { -public interface ProverInterface { - +public interface PresentationInterface { @Throws(AnoncredsException::class) - fun `createCredentialRequest`(`entropy`: String?, `proverDid`: String?, `credDef`: CredentialDefinition, `linkSecret`: LinkSecret, `linkSecretId`: String, `credentialOffer`: CredentialOffer): CreateCrendentialRequestResponse + fun `getJson`(): String +} + +class Presentation( + pointer: Pointer +) : FFIObject(pointer), PresentationInterface { + constructor(`jsonString`: String) : + this( + rustCallWithError(AnoncredsException) { _status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_presentation_new(FfiConverterString.lower(`jsonString`),_status) +}) + + /** + * Disconnect the object from the underlying Rust object. + * + * It can be called more than once, but once called, interacting with the object + * causes an `IllegalStateException`. + * + * Clients **must** call this method once done with the object, or cause a memory leak. + */ + override protected fun freeRustArcPtr() { + rustCall() { status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_presentation(this.pointer, status) + } + } + + + @Throws(AnoncredsException::class)override fun `getJson`(): String = + callWithPointer { + rustCallWithError(AnoncredsException) { _status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_presentation_get_json(it, + + _status) +} + }.let { + FfiConverterString.lift(it) + } + + + +} + +public object FfiConverterTypePresentation: FfiConverter { + override fun lower(value: Presentation): Pointer = value.callWithPointer { it } + + override fun lift(value: Pointer): Presentation { + return Presentation(value) + } + + override fun read(buf: ByteBuffer): Presentation { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: Presentation) = 8 + + override fun write(value: Presentation, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + + + +public interface PresentationRequestInterface { @Throws(AnoncredsException::class) - fun `processCredential`(`credential`: Credential, `credRequestMetadata`: CredentialRequestMetadata, `linkSecret`: LinkSecret, `credDef`: CredentialDefinition, `revRegDef`: RevocationRegistryDefinition?) + fun `getJson`(): String +} + +class PresentationRequest( + pointer: Pointer +) : FFIObject(pointer), PresentationRequestInterface { + constructor(`jsonString`: String) : + this( + rustCallWithError(AnoncredsException) { _status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_presentationrequest_new(FfiConverterString.lower(`jsonString`),_status) +}) + + /** + * Disconnect the object from the underlying Rust object. + * + * It can be called more than once, but once called, interacting with the object + * causes an `IllegalStateException`. + * + * Clients **must** call this method once done with the object, or cause a memory leak. + */ + override protected fun freeRustArcPtr() { + rustCall() { status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_presentationrequest(this.pointer, status) + } + } + - fun `createLinkSecret`(): LinkSecret + @Throws(AnoncredsException::class)override fun `getJson`(): String = + callWithPointer { + rustCallWithError(AnoncredsException) { _status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_presentationrequest_get_json(it, + + _status) +} + }.let { + FfiConverterString.lift(it) + } + + + +} + +public object FfiConverterTypePresentationRequest: FfiConverter { + override fun lower(value: PresentationRequest): Pointer = value.callWithPointer { it } + + override fun lift(value: Pointer): PresentationRequest { + return PresentationRequest(value) + } + + override fun read(buf: ByteBuffer): PresentationRequest { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: PresentationRequest) = 8 + + override fun write(value: PresentationRequest, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + + + +public interface ProverInterface { + @Throws(AnoncredsException::class) + fun `createCredentialRequest`(`entropy`: String?, `proverDid`: String?, `credDef`: CredentialDefinition, `linkSecret`: LinkSecret, `linkSecretId`: String, `credentialOffer`: CredentialOffer): CreateCrendentialRequestResponse@Throws(AnoncredsException::class) + fun `processCredential`(`credential`: Credential, `credRequestMetadata`: CredentialRequestMetadata, `linkSecret`: LinkSecret, `credDef`: CredentialDefinition, `revRegDef`: RevocationRegistryDefinition?)@Throws(AnoncredsException::class) + fun `createPresentation`(`presentationRequest`: PresentationRequest, `credentials`: List, `selfAttested`: Map?, `linkSecret`: LinkSecret, `schemas`: Map, `credentialDefinitions`: Map): Presentation + fun `createLinkSecret`(): LinkSecret } class Prover( @@ -1833,7 +2375,7 @@ class Prover( constructor() : this( rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Prover_new( _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_prover_new(_status) }) /** @@ -1846,7 +2388,7 @@ class Prover( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_Prover_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_prover(this.pointer, status) } } @@ -1854,28 +2396,49 @@ class Prover( @Throws(AnoncredsException::class)override fun `createCredentialRequest`(`entropy`: String?, `proverDid`: String?, `credDef`: CredentialDefinition, `linkSecret`: LinkSecret, `linkSecretId`: String, `credentialOffer`: CredentialOffer): CreateCrendentialRequestResponse = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Prover_create_credential_request(it, FfiConverterOptionalString.lower(`entropy`), FfiConverterOptionalString.lower(`proverDid`), FfiConverterTypeCredentialDefinition.lower(`credDef`), FfiConverterTypeLinkSecret.lower(`linkSecret`), FfiConverterString.lower(`linkSecretId`), FfiConverterTypeCredentialOffer.lower(`credentialOffer`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_prover_create_credential_request(it, + FfiConverterOptionalString.lower(`entropy`),FfiConverterOptionalString.lower(`proverDid`),FfiConverterTypeCredentialDefinition.lower(`credDef`),FfiConverterTypeLinkSecret.lower(`linkSecret`),FfiConverterString.lower(`linkSecretId`),FfiConverterTypeCredentialOffer.lower(`credentialOffer`), + _status) } }.let { FfiConverterTypeCreateCrendentialRequestResponse.lift(it) } + @Throws(AnoncredsException::class)override fun `processCredential`(`credential`: Credential, `credRequestMetadata`: CredentialRequestMetadata, `linkSecret`: LinkSecret, `credDef`: CredentialDefinition, `revRegDef`: RevocationRegistryDefinition?) = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Prover_process_credential(it, FfiConverterTypeCredential.lower(`credential`), FfiConverterTypeCredentialRequestMetadata.lower(`credRequestMetadata`), FfiConverterTypeLinkSecret.lower(`linkSecret`), FfiConverterTypeCredentialDefinition.lower(`credDef`), FfiConverterOptionalTypeRevocationRegistryDefinition.lower(`revRegDef`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_prover_process_credential(it, + FfiConverterTypeCredential.lower(`credential`),FfiConverterTypeCredentialRequestMetadata.lower(`credRequestMetadata`),FfiConverterTypeLinkSecret.lower(`linkSecret`),FfiConverterTypeCredentialDefinition.lower(`credDef`),FfiConverterOptionalTypeRevocationRegistryDefinition.lower(`revRegDef`), + _status) +} + } + + + + @Throws(AnoncredsException::class)override fun `createPresentation`(`presentationRequest`: PresentationRequest, `credentials`: List, `selfAttested`: Map?, `linkSecret`: LinkSecret, `schemas`: Map, `credentialDefinitions`: Map): Presentation = + callWithPointer { + rustCallWithError(AnoncredsException) { _status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_prover_create_presentation(it, + FfiConverterTypePresentationRequest.lower(`presentationRequest`),FfiConverterSequenceTypeCredentialRequests.lower(`credentials`),FfiConverterOptionalMapStringString.lower(`selfAttested`),FfiConverterTypeLinkSecret.lower(`linkSecret`),FfiConverterMapTypeSchemaIdTypeSchema.lower(`schemas`),FfiConverterMapTypeCredentialDefinitionIdTypeCredentialDefinition.lower(`credentialDefinitions`), + _status) } + }.let { + FfiConverterTypePresentation.lift(it) } override fun `createLinkSecret`(): LinkSecret = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_Prover_create_link_secret(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_prover_create_link_secret(it, + + _status) } }.let { FfiConverterTypeLinkSecret.lift(it) } + } @@ -1908,16 +2471,10 @@ public object FfiConverterTypeProver: FfiConverter { public interface RevocationRegistryDefinitionInterface { fun `getIssuerId`(): IssuerId - fun `getTag`(): String - fun `getCredDefId`(): CredentialDefinitionId - - fun `getValue`(): RevocationRegistryDefinitionValue - - @Throws(AnoncredsException::class) + fun `getValue`(): RevocationRegistryDefinitionValue@Throws(AnoncredsException::class) fun `getJson`(): String - } class RevocationRegistryDefinition( @@ -1926,7 +2483,7 @@ class RevocationRegistryDefinition( constructor(`jsonString`: String) : this( rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinition_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_revocationregistrydefinition_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -1939,52 +2496,67 @@ class RevocationRegistryDefinition( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_RevocationRegistryDefinition_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_revocationregistrydefinition(this.pointer, status) } } override fun `getIssuerId`(): IssuerId = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinition_get_issuer_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinition_get_issuer_id(it, + + _status) } }.let { FfiConverterTypeIssuerId.lift(it) } + override fun `getTag`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinition_get_tag(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinition_get_tag(it, + + _status) } }.let { FfiConverterString.lift(it) } + override fun `getCredDefId`(): CredentialDefinitionId = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinition_get_cred_def_id(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinition_get_cred_def_id(it, + + _status) } }.let { FfiConverterTypeCredentialDefinitionId.lift(it) } + override fun `getValue`(): RevocationRegistryDefinitionValue = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinition_get_value(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinition_get_value(it, + + _status) } }.let { FfiConverterTypeRevocationRegistryDefinitionValue.lift(it) } + @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinition_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinition_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -2015,10 +2587,8 @@ public object FfiConverterTypeRevocationRegistryDefinition: FfiConverter - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionPrivate_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_revocationregistrydefinitionprivate_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -2040,7 +2610,7 @@ class RevocationRegistryDefinitionPrivate( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_RevocationRegistryDefinitionPrivate_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_revocationregistrydefinitionprivate(this.pointer, status) } } @@ -2048,12 +2618,15 @@ class RevocationRegistryDefinitionPrivate( @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionPrivate_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinitionprivate_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -2086,14 +2659,9 @@ public object FfiConverterTypeRevocationRegistryDefinitionPrivate: FfiConverter< public interface RevocationRegistryDefinitionValueInterface { fun `getMaxCredNum`(): UInt - fun `getTailsHash`(): String - - fun `getTailsLocation`(): String - - @Throws(AnoncredsException::class) + fun `getTailsLocation`(): String@Throws(AnoncredsException::class) fun `getJson`(): String - } class RevocationRegistryDefinitionValue( @@ -2102,7 +2670,7 @@ class RevocationRegistryDefinitionValue( constructor(`jsonString`: String) : this( rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionValue_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_revocationregistrydefinitionvalue_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -2115,44 +2683,56 @@ class RevocationRegistryDefinitionValue( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_RevocationRegistryDefinitionValue_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_revocationregistrydefinitionvalue(this.pointer, status) } } override fun `getMaxCredNum`(): UInt = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionValue_get_max_cred_num(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinitionvalue_get_max_cred_num(it, + + _status) } }.let { FfiConverterUInt.lift(it) } + override fun `getTailsHash`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionValue_get_tails_hash(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinitionvalue_get_tails_hash(it, + + _status) } }.let { FfiConverterString.lift(it) } + override fun `getTailsLocation`(): String = callWithPointer { rustCall() { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionValue_get_tails_location(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinitionvalue_get_tails_location(it, + + _status) } }.let { FfiConverterString.lift(it) } + @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionValue_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinitionvalue_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -2183,10 +2763,8 @@ public object FfiConverterTypeRevocationRegistryDefinitionValue: FfiConverter - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionValuePublicKeys_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_revocationregistrydefinitionvaluepublickeys_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -2208,7 +2786,7 @@ class RevocationRegistryDefinitionValuePublicKeys( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_RevocationRegistryDefinitionValuePublicKeys_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_revocationregistrydefinitionvaluepublickeys(this.pointer, status) } } @@ -2216,12 +2794,15 @@ class RevocationRegistryDefinitionValuePublicKeys( @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationRegistryDefinitionValuePublicKeys_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationregistrydefinitionvaluepublickeys_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -2252,10 +2833,8 @@ public object FfiConverterTypeRevocationRegistryDefinitionValuePublicKeys: FfiCo public interface RevocationStatusListInterface { - @Throws(AnoncredsException::class) fun `getJson`(): String - } class RevocationStatusList( @@ -2264,7 +2843,7 @@ class RevocationStatusList( constructor(`jsonString`: String) : this( rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationStatusList_new(FfiConverterString.lower(`jsonString`), _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_revocationstatuslist_new(FfiConverterString.lower(`jsonString`),_status) }) /** @@ -2277,7 +2856,7 @@ class RevocationStatusList( */ override protected fun freeRustArcPtr() { rustCall() { status -> - _UniFFILib.INSTANCE.ffi_anoncreds_d8c0_RevocationStatusList_object_free(this.pointer, status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_revocationstatuslist(this.pointer, status) } } @@ -2285,12 +2864,15 @@ class RevocationStatusList( @Throws(AnoncredsException::class)override fun `getJson`(): String = callWithPointer { rustCallWithError(AnoncredsException) { _status -> - _UniFFILib.INSTANCE.anoncreds_d8c0_RevocationStatusList_get_json(it, _status) + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_revocationstatuslist_get_json(it, + + _status) } }.let { FfiConverterString.lift(it) } + } @@ -2320,16 +2902,86 @@ public object FfiConverterTypeRevocationStatusList: FfiConverter, `credentialDefinitions`: Map): Boolean } -public object FfiConverterTypeAttributeValues: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): AttributeValues { - return AttributeValues( +class Verifier( + pointer: Pointer +) : FFIObject(pointer), VerifierInterface { + constructor() : + this( + rustCall() { _status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_constructor_verifier_new(_status) +}) + + /** + * Disconnect the object from the underlying Rust object. + * + * It can be called more than once, but once called, interacting with the object + * causes an `IllegalStateException`. + * + * Clients **must** call this method once done with the object, or cause a memory leak. + */ + override protected fun freeRustArcPtr() { + rustCall() { status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_free_verifier(this.pointer, status) + } + } + + + @Throws(AnoncredsException::class)override fun `verifyPresentation`(`presentation`: Presentation, `presentationRequest`: PresentationRequest, `schemas`: Map, `credentialDefinitions`: Map): Boolean = + callWithPointer { + rustCallWithError(AnoncredsException) { _status -> + _UniFFILib.INSTANCE.uniffi_anoncreds_fn_method_verifier_verify_presentation(it, + FfiConverterTypePresentation.lower(`presentation`),FfiConverterTypePresentationRequest.lower(`presentationRequest`),FfiConverterMapTypeSchemaIdTypeSchema.lower(`schemas`),FfiConverterMapTypeCredentialDefinitionIdTypeCredentialDefinition.lower(`credentialDefinitions`), + _status) +} + }.let { + FfiConverterBoolean.lift(it) + } + + + + +} + +public object FfiConverterTypeVerifier: FfiConverter { + override fun lower(value: Verifier): Pointer = value.callWithPointer { it } + + override fun lift(value: Pointer): Verifier { + return Verifier(value) + } + + override fun read(buf: ByteBuffer): Verifier { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: Verifier) = 8 + + override fun write(value: Verifier, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + + + +data class AttributeValues ( + var `raw`: String, + var `encoded`: String +) { + +} + +public object FfiConverterTypeAttributeValues: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): AttributeValues { + return AttributeValues( FfiConverterString.read(buf), FfiConverterString.read(buf), ) @@ -2482,6 +3134,48 @@ public object FfiConverterTypeCredentialRequestMetadata: FfiConverterRustBuffer< +data class CredentialRequests ( + var `credential`: Credential, + var `requestedAttribute`: List, + var `requestedPredicate`: List +) : Disposable { + + @Suppress("UNNECESSARY_SAFE_CALL") // codegen is much simpler if we unconditionally emit safe calls here + override fun destroy() { + + Disposable.destroy( + this.`credential`, + this.`requestedAttribute`, + this.`requestedPredicate`) + } + +} + +public object FfiConverterTypeCredentialRequests: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): CredentialRequests { + return CredentialRequests( + FfiConverterTypeCredential.read(buf), + FfiConverterSequenceTypeRequestedAttribute.read(buf), + FfiConverterSequenceTypeRequestedPredicate.read(buf), + ) + } + + override fun allocationSize(value: CredentialRequests) = ( + FfiConverterTypeCredential.allocationSize(value.`credential`) + + FfiConverterSequenceTypeRequestedAttribute.allocationSize(value.`requestedAttribute`) + + FfiConverterSequenceTypeRequestedPredicate.allocationSize(value.`requestedPredicate`) + ) + + override fun write(value: CredentialRequests, buf: ByteBuffer) { + FfiConverterTypeCredential.write(value.`credential`, buf) + FfiConverterSequenceTypeRequestedAttribute.write(value.`requestedAttribute`, buf) + FfiConverterSequenceTypeRequestedPredicate.write(value.`requestedPredicate`, buf) + } +} + + + + data class CredentialRevocationConfig ( var `regDef`: RevocationRegistryDefinition, var `regDefPrivate`: RevocationRegistryDefinitionPrivate, @@ -2533,16 +3227,16 @@ data class CredentialValues ( public object FfiConverterTypeCredentialValues: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): CredentialValues { return CredentialValues( - FfiConverterMapStringAttributeValues.read(buf), + FfiConverterMapStringTypeAttributeValues.read(buf), ) } override fun allocationSize(value: CredentialValues) = ( - FfiConverterMapStringAttributeValues.allocationSize(value.`values`) + FfiConverterMapStringTypeAttributeValues.allocationSize(value.`values`) ) override fun write(value: CredentialValues, buf: ByteBuffer) { - FfiConverterMapStringAttributeValues.write(value.`values`, buf) + FfiConverterMapStringTypeAttributeValues.write(value.`values`, buf) } } @@ -2628,81 +3322,91 @@ public object FfiConverterTypeIssuerCreateRevocationRegistryDefReturn: FfiConver -data class Schema ( - var `name`: String, - var `version`: String, - var `attrNames`: AttributeNames, - var `issuerId`: IssuerId +data class RequestedAttribute ( + var `referent`: String, + var `revealed`: Boolean ) { } -public object FfiConverterTypeSchema: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): Schema { - return Schema( - FfiConverterString.read(buf), +public object FfiConverterTypeRequestedAttribute: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): RequestedAttribute { + return RequestedAttribute( FfiConverterString.read(buf), - FfiConverterTypeAttributeNames.read(buf), - FfiConverterTypeIssuerId.read(buf), + FfiConverterBoolean.read(buf), ) } - override fun allocationSize(value: Schema) = ( - FfiConverterString.allocationSize(value.`name`) + - FfiConverterString.allocationSize(value.`version`) + - FfiConverterTypeAttributeNames.allocationSize(value.`attrNames`) + - FfiConverterTypeIssuerId.allocationSize(value.`issuerId`) + override fun allocationSize(value: RequestedAttribute) = ( + FfiConverterString.allocationSize(value.`referent`) + + FfiConverterBoolean.allocationSize(value.`revealed`) ) - override fun write(value: Schema, buf: ByteBuffer) { - FfiConverterString.write(value.`name`, buf) - FfiConverterString.write(value.`version`, buf) - FfiConverterTypeAttributeNames.write(value.`attrNames`, buf) - FfiConverterTypeIssuerId.write(value.`issuerId`, buf) + override fun write(value: RequestedAttribute, buf: ByteBuffer) { + FfiConverterString.write(value.`referent`, buf) + FfiConverterBoolean.write(value.`revealed`, buf) } } -enum class RegistryType { - CL_ACCUM; +data class RequestedPredicate ( + var `referent`: String +) { + } -public object FfiConverterTypeRegistryType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer) = try { - RegistryType.values()[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) +public object FfiConverterTypeRequestedPredicate: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): RequestedPredicate { + return RequestedPredicate( + FfiConverterString.read(buf), + ) } - override fun allocationSize(value: RegistryType) = 4 + override fun allocationSize(value: RequestedPredicate) = ( + FfiConverterString.allocationSize(value.`referent`) + ) - override fun write(value: RegistryType, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) + override fun write(value: RequestedPredicate, buf: ByteBuffer) { + FfiConverterString.write(value.`referent`, buf) } } - - -enum class SignatureType { - CL; +data class Schema ( + var `name`: String, + var `version`: String, + var `attrNames`: AttributeNames, + var `issuerId`: IssuerId +) { + } -public object FfiConverterTypeSignatureType: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer) = try { - SignatureType.values()[buf.getInt() - 1] - } catch (e: IndexOutOfBoundsException) { - throw RuntimeException("invalid enum value, something is very wrong!!", e) +public object FfiConverterTypeSchema: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): Schema { + return Schema( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterTypeAttributeNames.read(buf), + FfiConverterTypeIssuerId.read(buf), + ) } - override fun allocationSize(value: SignatureType) = 4 + override fun allocationSize(value: Schema) = ( + FfiConverterString.allocationSize(value.`name`) + + FfiConverterString.allocationSize(value.`version`) + + FfiConverterTypeAttributeNames.allocationSize(value.`attrNames`) + + FfiConverterTypeIssuerId.allocationSize(value.`issuerId`) + ) - override fun write(value: SignatureType, buf: ByteBuffer) { - buf.putInt(value.ordinal + 1) + override fun write(value: Schema, buf: ByteBuffer) { + FfiConverterString.write(value.`name`, buf) + FfiConverterString.write(value.`version`, buf) + FfiConverterTypeAttributeNames.write(value.`attrNames`, buf) + FfiConverterTypeIssuerId.write(value.`issuerId`, buf) } } @@ -2710,8 +3414,6 @@ public object FfiConverterTypeSignatureType: FfiConverterRustBuffer { @@ -2748,26 +3452,125 @@ public object FfiConverterTypeAnoncredsError : FfiConverterRustBuffer AnoncredsException.CreateCredentialOffer(FfiConverterString.read(buf)) 10 -> AnoncredsException.CreateCredential(FfiConverterString.read(buf)) 11 -> AnoncredsException.ProcessCredential(FfiConverterString.read(buf)) + 12 -> AnoncredsException.CreatePresentationException(FfiConverterString.read(buf)) + 13 -> AnoncredsException.ProcessCredentialException(FfiConverterString.read(buf)) else -> throw RuntimeException("invalid error enum value, something is very wrong!!") } } - @Suppress("UNUSED_PARAMETER") override fun allocationSize(value: AnoncredsException): Int { - throw RuntimeException("Writing Errors is not supported") + return 4 } - @Suppress("UNUSED_PARAMETER") override fun write(value: AnoncredsException, buf: ByteBuffer) { - throw RuntimeException("Writing Errors is not supported") + when(value) { + is AnoncredsException.ConversionException -> { + buf.putInt(1) + Unit + } + is AnoncredsException.SomethingWentWrong -> { + buf.putInt(2) + Unit + } + is AnoncredsException.CreateCrentialRequestException -> { + buf.putInt(3) + Unit + } + is AnoncredsException.CreateSchemaException -> { + buf.putInt(4) + Unit + } + is AnoncredsException.CreateCredentialDefinition -> { + buf.putInt(5) + Unit + } + is AnoncredsException.CreateRevocationRegistryDef -> { + buf.putInt(6) + Unit + } + is AnoncredsException.CreateRevocationStatusList -> { + buf.putInt(7) + Unit + } + is AnoncredsException.UpdateRevocationStatusList -> { + buf.putInt(8) + Unit + } + is AnoncredsException.CreateCredentialOffer -> { + buf.putInt(9) + Unit + } + is AnoncredsException.CreateCredential -> { + buf.putInt(10) + Unit + } + is AnoncredsException.ProcessCredential -> { + buf.putInt(11) + Unit + } + is AnoncredsException.CreatePresentationException -> { + buf.putInt(12) + Unit + } + is AnoncredsException.ProcessCredentialException -> { + buf.putInt(13) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } + +} + + + + +enum class RegistryType { + CL_ACCUM; +} + +public object FfiConverterTypeRegistryType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + RegistryType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: RegistryType) = 4 + + override fun write(value: RegistryType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + + +enum class SignatureType { + CL; +} + +public object FfiConverterTypeSignatureType: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer) = try { + SignatureType.values()[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) } + override fun allocationSize(value: SignatureType) = 4 + + override fun write(value: SignatureType, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } } + + public object FfiConverterOptionalULong: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): ULong? { if (buf.get().toInt() == 0) { @@ -2942,6 +3745,35 @@ public object FfiConverterOptionalSequenceUInt: FfiConverterRustBuffer?> { + override fun read(buf: ByteBuffer): Map? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterMapStringString.read(buf) + } + + override fun allocationSize(value: Map?): Int { + if (value == null) { + return 1 + } else { + return 1 + FfiConverterMapStringString.allocationSize(value) + } + } + + override fun write(value: Map?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterMapStringString.write(value, buf) + } + } +} + + + + public object FfiConverterOptionalTypeRevocationRegistryId: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): RevocationRegistryId? { if (buf.get().toInt() == 0) { @@ -3045,7 +3877,118 @@ public object FfiConverterSequenceTypeAttributeValues: FfiConverterRustBuffer
  • > { + +public object FfiConverterSequenceTypeCredentialRequests: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeCredentialRequests.read(buf) + } + } + + override fun allocationSize(value: List): Int { + val sizeForLength = 4 + val sizeForItems = value.map { FfiConverterTypeCredentialRequests.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.forEach { + FfiConverterTypeCredentialRequests.write(it, buf) + } + } +} + + + + +public object FfiConverterSequenceTypeRequestedAttribute: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeRequestedAttribute.read(buf) + } + } + + override fun allocationSize(value: List): Int { + val sizeForLength = 4 + val sizeForItems = value.map { FfiConverterTypeRequestedAttribute.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.forEach { + FfiConverterTypeRequestedAttribute.write(it, buf) + } + } +} + + + + +public object FfiConverterSequenceTypeRequestedPredicate: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeRequestedPredicate.read(buf) + } + } + + override fun allocationSize(value: List): Int { + val sizeForLength = 4 + val sizeForItems = value.map { FfiConverterTypeRequestedPredicate.allocationSize(it) }.sum() + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.forEach { + FfiConverterTypeRequestedPredicate.write(it, buf) + } + } +} + + + +public object FfiConverterMapStringString: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): Map { + // TODO: Once Kotlin's `buildMap` API is stabilized we should use it here. + val items : MutableMap = mutableMapOf() + val len = buf.getInt() + repeat(len) { + val k = FfiConverterString.read(buf) + val v = FfiConverterString.read(buf) + items[k] = v + } + return items + } + + override fun allocationSize(value: Map): Int { + val spaceForMapSize = 4 + val spaceForChildren = value.map { (k, v) -> + FfiConverterString.allocationSize(k) + + FfiConverterString.allocationSize(v) + }.sum() + return spaceForMapSize + spaceForChildren + } + + override fun write(value: Map, buf: ByteBuffer) { + buf.putInt(value.size) + // The parens on `(k, v)` here ensure we're calling the right method, + // which is important for compatibility with older android devices. + // Ref https://blog.danlew.net/2017/03/16/kotlin-puzzler-whose-line-is-it-anyways/ + value.forEach { (k, v) -> + FfiConverterString.write(k, buf) + FfiConverterString.write(v, buf) + } + } +} + + + +public object FfiConverterMapStringTypeAttributeValues: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): Map { // TODO: Once Kotlin's `buildMap` API is stabilized we should use it here. val items : MutableMap = mutableMapOf() @@ -3081,6 +4024,78 @@ public object FfiConverterMapStringAttributeValues: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): Map { + // TODO: Once Kotlin's `buildMap` API is stabilized we should use it here. + val items : MutableMap = mutableMapOf() + val len = buf.getInt() + repeat(len) { + val k = FfiConverterTypeCredentialDefinitionId.read(buf) + val v = FfiConverterTypeCredentialDefinition.read(buf) + items[k] = v + } + return items + } + + override fun allocationSize(value: Map): Int { + val spaceForMapSize = 4 + val spaceForChildren = value.map { (k, v) -> + FfiConverterTypeCredentialDefinitionId.allocationSize(k) + + FfiConverterTypeCredentialDefinition.allocationSize(v) + }.sum() + return spaceForMapSize + spaceForChildren + } + + override fun write(value: Map, buf: ByteBuffer) { + buf.putInt(value.size) + // The parens on `(k, v)` here ensure we're calling the right method, + // which is important for compatibility with older android devices. + // Ref https://blog.danlew.net/2017/03/16/kotlin-puzzler-whose-line-is-it-anyways/ + value.forEach { (k, v) -> + FfiConverterTypeCredentialDefinitionId.write(k, buf) + FfiConverterTypeCredentialDefinition.write(v, buf) + } + } +} + + + +public object FfiConverterMapTypeSchemaIdTypeSchema: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): Map { + // TODO: Once Kotlin's `buildMap` API is stabilized we should use it here. + val items : MutableMap = mutableMapOf() + val len = buf.getInt() + repeat(len) { + val k = FfiConverterTypeSchemaId.read(buf) + val v = FfiConverterTypeSchema.read(buf) + items[k] = v + } + return items + } + + override fun allocationSize(value: Map): Int { + val spaceForMapSize = 4 + val spaceForChildren = value.map { (k, v) -> + FfiConverterTypeSchemaId.allocationSize(k) + + FfiConverterTypeSchema.allocationSize(v) + }.sum() + return spaceForMapSize + spaceForChildren + } + + override fun write(value: Map, buf: ByteBuffer) { + buf.putInt(value.size) + // The parens on `(k, v)` here ensure we're calling the right method, + // which is important for compatibility with older android devices. + // Ref https://blog.danlew.net/2017/03/16/kotlin-puzzler-whose-line-is-it-anyways/ + value.forEach { (k, v) -> + FfiConverterTypeSchemaId.write(k, buf) + FfiConverterTypeSchema.write(v, buf) + } + } +} + + + /** * Typealias from the type name used in the UDL file to the builtin type. This * is needed because the UDL type name is used in function/method signatures. @@ -3139,4 +4154,3 @@ public typealias FfiConverterTypeRevocationRegistryId = FfiConverterString public typealias SchemaId = String public typealias FfiConverterTypeSchemaId = FfiConverterString - diff --git a/uniffi/src/anoncreds.udl b/uniffi/src/anoncreds.udl index 76709fae..a786314a 100644 --- a/uniffi/src/anoncreds.udl +++ b/uniffi/src/anoncreds.udl @@ -24,6 +24,8 @@ enum AnoncredsError { "CreateCredentialOffer", "CreateCredential", "ProcessCredential", + "CreatePresentationError", + "ProcessCredentialError", }; enum SignatureType { @@ -296,15 +298,65 @@ interface Prover { ); [Throws=AnoncredsError] - void process_credential( - Credential credential, - CredentialRequestMetadata cred_request_metadata, - LinkSecret link_secret, - CredentialDefinition cred_def, - RevocationRegistryDefinition? rev_reg_def - ); + void process_credential( + Credential credential, + CredentialRequestMetadata cred_request_metadata, + LinkSecret link_secret, + CredentialDefinition cred_def, + RevocationRegistryDefinition? rev_reg_def + ); + + [Throws=AnoncredsError] + Presentation create_presentation( + PresentationRequest presentation_request, + sequence credentials, + record? self_attested, + LinkSecret link_secret, + record schemas, + record credential_definitions + ); LinkSecret create_link_secret(); }; +dictionary RequestedAttribute { + string referent; + boolean revealed; +}; +dictionary RequestedPredicate { + string referent; +}; +dictionary CredentialRequests { + Credential credential; + sequence requested_attribute; + sequence requested_predicate; +}; + +interface Presentation { + [Throws=AnoncredsError] + constructor(string json_string); + [Throws=AnoncredsError] + string get_json(); +}; + +interface PresentationRequest { + [Throws=AnoncredsError] + constructor(string json_string); + [Throws=AnoncredsError] + string get_json(); +}; + +interface Verifier { + constructor(); + + [Throws=AnoncredsError] + boolean verify_presentation( + Presentation presentation, + PresentationRequest presentation_request, + record schemas, + record credential_definitions + ); + +}; + namespace anoncreds {}; \ No newline at end of file diff --git a/uniffi/src/issuer/mod.rs b/uniffi/src/issuer/mod.rs index 03aa87a6..1ca474ae 100644 --- a/uniffi/src/issuer/mod.rs +++ b/uniffi/src/issuer/mod.rs @@ -1,7 +1,7 @@ use crate::types::error::AnoncredsError; use crate::types::cred_def::{CredentialDefinition, CredentialDefinitionPrivate, CredentialKeyCorrectnessProof}; -use crate::types::cred_offer::{CredentialOffer}; -use crate::types::credential::{Credential}; +use crate::types::cred_offer::CredentialOffer; +use crate::types::credential::Credential; use crate::CredentialRequest; use crate::types::rev_status_list::RevocationStatusList; use crate::types::rev_reg_def::{RevocationRegistryDefinition, RevocationRegistryDefinitionPrivate}; diff --git a/uniffi/src/lib.rs b/uniffi/src/lib.rs index 5727f97e..c9bff623 100644 --- a/uniffi/src/lib.rs +++ b/uniffi/src/lib.rs @@ -1,33 +1,41 @@ mod types; // mod issuer; -mod prover; mod issuer; +mod prover; +mod verifier; -pub use anoncreds_core::data_types::cred_def::CredentialDefinitionId; -pub use anoncreds_core::data_types::issuer_id::IssuerId; -pub use anoncreds_core::data_types::rev_reg::RevocationRegistryId; -pub use anoncreds_core::data_types::rev_reg_def::RevocationRegistryDefinitionId; -pub use anoncreds_core::data_types::schema::{Schema, SchemaId}; -pub use anoncreds_core::types::{AttributeNames, CredentialDefinitionConfig, SignatureType, RegistryType}; -pub use crate::types::cred_def::{CredentialDefinition, CredentialDefinitionData, CredentialKeyCorrectnessProof}; -pub use crate::types::link_secret::LinkSecret; -pub use crate::types::nonce::Nonce; -pub use crate::types::error::AnoncredsError; +pub use crate::cred_def::CredentialDefinitionPrivate; +pub use crate::custom_types::{AttributeValues, CredentialValues}; +pub use crate::types::cred_def::{ + CredentialDefinition, CredentialDefinitionData, CredentialKeyCorrectnessProof, +}; pub use crate::types::cred_offer::CredentialOffer; pub use crate::types::cred_req::{CredentialRequest, CredentialRequestMetadata}; pub use crate::types::credential::Credential; -pub use crate::types::rev_reg_def::RevocationRegistryDefinitionPrivate; +pub use crate::types::error::AnoncredsError; +pub use crate::types::link_secret::LinkSecret; +pub use crate::types::nonce::Nonce; +pub use crate::types::presentation::Presentation; +pub use crate::types::presentation::PresentationRequest; pub use crate::types::rev_reg_def::RevocationRegistryDefinition; -pub use crate::types::rev_reg_def::RevocationRegistryDefinitionValuePublicKeys; +pub use crate::types::rev_reg_def::RevocationRegistryDefinitionPrivate; pub use crate::types::rev_reg_def::RevocationRegistryDefinitionValue; +pub use crate::types::rev_reg_def::RevocationRegistryDefinitionValuePublicKeys; pub use crate::types::rev_status_list::RevocationStatusList; -pub use crate::cred_def::CredentialDefinitionPrivate; -pub use crate::custom_types::{AttributeValues, CredentialValues}; +pub use anoncreds_core::data_types::cred_def::CredentialDefinitionId; +pub use anoncreds_core::data_types::issuer_id::IssuerId; +pub use anoncreds_core::data_types::rev_reg::RevocationRegistryId; +pub use anoncreds_core::data_types::rev_reg_def::RevocationRegistryDefinitionId; +pub use anoncreds_core::data_types::schema::{Schema, SchemaId}; +pub use anoncreds_core::types::{ + AttributeNames, CredentialDefinitionConfig, RegistryType, SignatureType, +}; -pub use types::*; pub use issuer::CredentialRevocationConfig; -pub use prover::*; pub use issuer::*; +pub use prover::*; +pub use types::*; +pub use verifier::*; // fn x() -> AttributeValues diff --git a/uniffi/src/prover/mod.rs b/uniffi/src/prover/mod.rs index 8d522abe..e3ddd776 100644 --- a/uniffi/src/prover/mod.rs +++ b/uniffi/src/prover/mod.rs @@ -1,23 +1,37 @@ -use crate::types::link_secret::LinkSecret; use crate::error::AnoncredsError; -use crate::nonce::Nonce; +use crate::types::cred_def::CredentialDefinition; use crate::types::cred_offer::CredentialOffer; use crate::types::cred_req::{CredentialRequest, CredentialRequestMetadata}; -use crate::types::cred_def::{CredentialDefinition, CredentialDefinitionData}; -use crate::Credential; +use crate::types::link_secret::LinkSecret; +use crate::PresentationRequest; use crate::RevocationRegistryDefinition; -use anoncreds_core::prover::*; -use anoncreds_core::data_types::cred_request::{CredentialRequest as AnoncredsCredentialRequest, CredentialRequestMetadata as AnoncredsCredentialRequestMetadata}; -use anoncreds_core::types::Credential as AnoncredsCredential; -use super::types::*; -use std::sync::Arc; +use crate::{Credential, Presentation}; +use anoncreds_core::data_types::cred_def::CredentialDefinitionId; +use anoncreds_core::data_types::schema::{Schema, SchemaId}; +use anoncreds_core::prover; +use anoncreds_core::types::PresentCredentials as AnoncredsPresentCredentials; +use std::collections::HashMap; use std::convert::TryInto; +use std::sync::Arc; pub struct CreateCrendentialRequestResponse { pub request: Arc, pub metadata: CredentialRequestMetadata, } +pub struct RequestedAttribute { + pub referent: String, + pub revealed: bool, +} +pub struct RequestedPredicate { + pub referent: String, +} +pub struct CredentialRequests { + pub credential: Arc, + pub requested_attribute: Vec, + pub requested_predicate: Vec, +} + pub struct Prover {} impl Prover { @@ -42,24 +56,23 @@ impl Prover { let cred_def_clone = Arc::clone(&cred_def); let cred_def_inner = cred_def_clone.as_ref(); let cred_def_core = cred_def_inner.clone().try_into()?; - let link_secret_core =(*link_secret).clone().secret; + let link_secret_core = (*link_secret).clone().secret; let cred_offer_core = (*credential_offer).clone().core; - + let (request, metadata) = anoncreds_core::prover::create_credential_request( entropy.as_ref().map(|s| s.as_str()), prover_did.as_ref().map(|s| s.as_str()), &cred_def_core, &link_secret_core, link_secret_id.as_str(), - &cred_offer_core - ).map_err(|err| { - AnoncredsError::CreateCrentialRequestError(format!("Error: {}", err)) - })?; + &cred_offer_core, + ) + .map_err(|err| AnoncredsError::CreateCrentialRequestError(format!("Error: {}", err)))?; return Ok(CreateCrendentialRequestResponse { request: Arc::new(CredentialRequest { core: request }), - metadata: CredentialRequestMetadata::from(metadata) - }) + metadata: CredentialRequestMetadata::from(metadata), + }); } pub fn process_credential( @@ -70,15 +83,66 @@ impl Prover { cred_def: Arc, rev_reg_def: Option>, ) -> Result<(), AnoncredsError> { - let mut mutable_credential = (*credential).core.try_clone().map_err(|_| AnoncredsError::ConversionError)?; - process_credential( + let mut mutable_credential = (*credential) + .core + .try_clone() + .map_err(|_| AnoncredsError::ConversionError)?; + prover::process_credential( &mut mutable_credential, &cred_request_metadata.into(), &(*link_secret).secret, &(*cred_def).core, - rev_reg_def.as_ref().map(|def| &(*def).core) - ).map_err(|err| { - AnoncredsError::ProcessCredential(format!("Error: {}", err)) - }) + rev_reg_def.as_ref().map(|def| &(*def).core), + ) + .map_err(|err| AnoncredsError::ProcessCredential(format!("Error: {}", err))) + } + + pub fn create_presentation( + &self, + presentation_request: Arc, + credentials: Vec, + self_attested: Option>, + link_secret: Arc, + schemas: HashMap, + credential_definitions: HashMap>, + ) -> Result, AnoncredsError> { + let pres_req = &presentation_request.core; + + let mut present_credentials = AnoncredsPresentCredentials::default(); + let timestamp = None; // TODO + let rev_state = None; //TODO + + credentials.iter().for_each(|c| { + let cred = &c.credential.core; + let mut tmp = present_credentials.add_credential(cred, timestamp, rev_state); + + c.requested_attribute.iter().for_each(|attribute| { + tmp.add_requested_attribute(attribute.referent.to_string(), attribute.revealed); + }); + + c.requested_predicate.iter().for_each(|predicate| { + tmp.add_requested_predicate(predicate.referent.to_string()); + }); + }); + + let schemas_anoncreds = schemas.iter().map(|(k, v)| (k, v)).collect(); + let cred_defs = credential_definitions + .iter() + .map(|(k, v)| { + let tmp = &v.core; + (k, tmp) + }) + .collect(); + + return prover::create_presentation( + pres_req, + present_credentials, + self_attested, + &link_secret.secret, + &schemas_anoncreds, + &cred_defs, + ) + .map_err(|err| AnoncredsError::CreatePresentationError(format!("Error: {}", err))) + .map(|e| Arc::new(Presentation { core: e })); } -} \ No newline at end of file +} diff --git a/uniffi/src/types/cred_def.rs b/uniffi/src/types/cred_def.rs index d2938770..ddb38271 100644 --- a/uniffi/src/types/cred_def.rs +++ b/uniffi/src/types/cred_def.rs @@ -10,9 +10,6 @@ use anoncreds_core::data_types::cred_def::{ }; use std::convert::TryFrom; use std::convert::TryInto; -use serde::{Deserialize, Serialize}; -use serde_json::Result as SerdeResult; -use std::sync::Arc; #[derive(Clone)] pub struct CredentialDefinitionData { diff --git a/uniffi/src/types/cred_offer.rs b/uniffi/src/types/cred_offer.rs index 17cc6889..35e5a4cb 100644 --- a/uniffi/src/types/cred_offer.rs +++ b/uniffi/src/types/cred_offer.rs @@ -1,15 +1,9 @@ use crate::types::error::AnoncredsError; use crate::types::nonce::Nonce; use anoncreds_core::data_types::schema::SchemaId; -use anoncreds_core::data_types::cred_def::{ - CredentialDefinitionId, - SignatureType -}; -use anoncreds_core::data_types::cred_offer::{CredentialOffer as AnoncredsCredentialOffer}; +use anoncreds_core::data_types::cred_def::CredentialDefinitionId; +use anoncreds_core::data_types::cred_offer::CredentialOffer as AnoncredsCredentialOffer; use std::convert::TryFrom; -use std::convert::TryInto; -use serde::{Deserialize, Serialize}; -use serde_json::Result as SerdeResult; use std::sync::Arc; pub struct CredentialOffer { @@ -17,8 +11,8 @@ pub struct CredentialOffer { } impl CredentialOffer { - pub fn new(jsonString: String) -> Result { - let core_def: AnoncredsCredentialOffer = serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsCredentialOffer = serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; return Ok(CredentialOffer { core: core_def }) } diff --git a/uniffi/src/types/cred_req.rs b/uniffi/src/types/cred_req.rs index 03010e72..764aae9d 100644 --- a/uniffi/src/types/cred_req.rs +++ b/uniffi/src/types/cred_req.rs @@ -1,10 +1,6 @@ use crate::types::error::AnoncredsError; use crate::types::nonce::Nonce; use anoncreds_core::data_types::cred_request::{CredentialRequest as AnoncredsCredentialRequest, CredentialRequestMetadata as AnoncredsCredentialRequestMetadata}; -use std::convert::TryFrom; -use std::convert::TryInto; -use serde::{Deserialize, Serialize}; -use serde_json::Result as SerdeResult; use std::sync::Arc; pub struct CredentialRequest { @@ -12,9 +8,9 @@ pub struct CredentialRequest { } impl CredentialRequest { - pub fn new(jsonString: String) -> Result { + pub fn new(json_string: String) -> Result { let core_def: AnoncredsCredentialRequest = - serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; + serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; return Ok(CredentialRequest { core: core_def }); } @@ -42,9 +38,9 @@ pub struct CredentialRequestMetadata { } // impl CredentialRequestMetadata { -// pub fn new(jsonString: String) -> Result { +// pub fn new(json_string: String) -> Result { // let core_def: AnoncredsCredentialRequest = -// serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; +// serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; // return Ok(CredentialRequestMetadata { core: core_def }); // } diff --git a/uniffi/src/types/credential.rs b/uniffi/src/types/credential.rs index c8305e16..4ede0e56 100644 --- a/uniffi/src/types/credential.rs +++ b/uniffi/src/types/credential.rs @@ -1,11 +1,7 @@ use crate::types::error::AnoncredsError; -use crate::types::nonce::Nonce; pub use crate::custom_types::CredentialValues; use anoncreds_core::data_types::schema::SchemaId; -use anoncreds_core::data_types::cred_def::{ - CredentialDefinitionId, - SignatureType -}; +use anoncreds_core::data_types::cred_def::CredentialDefinitionId; use anoncreds_core::data_types::rev_reg::RevocationRegistryId; use anoncreds_core::data_types::credential::Credential as AnoncredsCredential; @@ -14,8 +10,8 @@ pub struct Credential { } impl Credential { - pub fn new(jsonString: String) -> Result { - let core_def: AnoncredsCredential = serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsCredential = serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; return Ok(Credential { core: core_def }) } diff --git a/uniffi/src/types/custom_types.rs b/uniffi/src/types/custom_types.rs index 30dc068b..f6f4dd60 100644 --- a/uniffi/src/types/custom_types.rs +++ b/uniffi/src/types/custom_types.rs @@ -1,4 +1,3 @@ -use crate::types::error::AnoncredsError; use anoncreds_core::data_types::schema::SchemaId; use anoncreds_core::data_types::issuer_id::IssuerId; use anoncreds_core::data_types::rev_reg::RevocationRegistryId; @@ -10,11 +9,7 @@ use anoncreds_core::types::{ }; use anoncreds_core::data_types::credential::CredentialValues as AnoncredsCredentialValues; use crate::UniffiCustomTypeConverter; -use std::convert::TryFrom; -use std::convert::TryInto; use std::collections::HashMap; -use serde::{Deserialize, Serialize}; -use serde_json::Result as SerdeResult; /// Make sure [AttributeNames] implements [UniffiCustomTypeConverter] so that UniFFI can use it as /// it is a Tuple Struct in Rust diff --git a/uniffi/src/types/error.rs b/uniffi/src/types/error.rs index 141a52ee..4bbb1d5c 100644 --- a/uniffi/src/types/error.rs +++ b/uniffi/src/types/error.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; pub enum AnoncredsError { #[error("Conversion Error")] ConversionError, - #[error("Something went wrong")] + #[error("Something went wrong")] SomethingWentWrong, #[error("Create Credential Error: {0}")] CreateCrentialRequestError(String), @@ -24,4 +24,9 @@ pub enum AnoncredsError { CreateCredential(String), #[error("Process Credential: {0}")] ProcessCredential(String), -} \ No newline at end of file + + #[error("Create Presentation: {0}")] + CreatePresentationError(String), + #[error("Verify Presentation: {0}")] + ProcessCredentialError(String), +} diff --git a/uniffi/src/types/link_secret.rs b/uniffi/src/types/link_secret.rs index 4ff8c1fa..636163f2 100644 --- a/uniffi/src/types/link_secret.rs +++ b/uniffi/src/types/link_secret.rs @@ -1,8 +1,6 @@ use crate::types::error::AnoncredsError; use anoncreds_core::data_types::link_secret::LinkSecret as AnoncredsLinkSecret; use std::convert::TryFrom; -use std::convert::TryInto; -use std::sync::Arc; pub struct LinkSecret { pub secret: AnoncredsLinkSecret, @@ -74,9 +72,10 @@ impl Clone for LinkSecret { #[cfg(test)] mod warp_link_secret_tests { use super::*; + use std::convert::TryInto; #[test] - fn should_serialize_and_deserialize_AnoncredsLinkSecret_into_the_same_value() { + fn should_serialize_and_deserialize_anoncreds_link_secret_into_the_same_value() { let link_secret = AnoncredsLinkSecret::new().expect("Error creating link secret"); let link_secret_srt: String = link_secret.try_into().expect("Error creating link secret"); // println!("{}", link_secret_srt); @@ -88,7 +87,7 @@ mod warp_link_secret_tests { } #[test] - fn should_serialize_and_deserialize_LinkSecret_into_the_same_value() { + fn should_serialize_and_deserialize_link_secret_into_the_same_value() { let link_secret = LinkSecret::new(); let link_secret_srt: String = link_secret.try_into().expect("Error creating link secret"); println!("{}", link_secret_srt); diff --git a/uniffi/src/types/mod.rs b/uniffi/src/types/mod.rs index 093c576f..4f3771e7 100644 --- a/uniffi/src/types/mod.rs +++ b/uniffi/src/types/mod.rs @@ -7,4 +7,5 @@ pub mod cred_offer; pub mod cred_req; pub mod rev_reg_def; pub mod credential; -pub mod rev_status_list; \ No newline at end of file +pub mod rev_status_list; +pub mod presentation; \ No newline at end of file diff --git a/uniffi/src/types/nonce.rs b/uniffi/src/types/nonce.rs index 8477264b..bfe15664 100644 --- a/uniffi/src/types/nonce.rs +++ b/uniffi/src/types/nonce.rs @@ -1,8 +1,6 @@ use crate::types::error::AnoncredsError; use anoncreds_core::data_types::nonce::Nonce as AnoncredsNonce; use std::convert::TryFrom; -use std::convert::TryInto; -use std::sync::Arc; pub struct Nonce { pub anoncreds_nonce: AnoncredsNonce, diff --git a/uniffi/src/types/presentation.rs b/uniffi/src/types/presentation.rs new file mode 100644 index 00000000..9d91c675 --- /dev/null +++ b/uniffi/src/types/presentation.rs @@ -0,0 +1,36 @@ +use anoncreds_core::types::Presentation as AnoncredsPresentation; +use anoncreds_core::types::PresentationRequest as AnoncredsPresentationRequest; + +use crate::AnoncredsError; + +pub struct Presentation { + pub core: AnoncredsPresentation, +} + +impl Presentation { + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsPresentation = + serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; + return Ok(Presentation { core: core_def }); + } + + pub fn get_json(&self) -> Result { + serde_json::to_string(&self.core).map_err(|_| AnoncredsError::ConversionError) + } +} + +pub struct PresentationRequest { + pub core: AnoncredsPresentationRequest, +} + +impl PresentationRequest { + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsPresentationRequest = + serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; + return Ok(PresentationRequest { core: core_def }); + } + + pub fn get_json(&self) -> Result { + serde_json::to_string(&self.core).map_err(|_| AnoncredsError::ConversionError) + } +} diff --git a/uniffi/src/types/rev_reg_def.rs b/uniffi/src/types/rev_reg_def.rs index 3f42b494..00b65fc3 100644 --- a/uniffi/src/types/rev_reg_def.rs +++ b/uniffi/src/types/rev_reg_def.rs @@ -1,5 +1,4 @@ use crate::types::error::AnoncredsError; -use anoncreds_core::data_types::schema::SchemaId; use anoncreds_core::data_types::issuer_id::IssuerId; use anoncreds_core::data_types::cred_def::CredentialDefinitionId; use anoncreds_core::data_types::rev_reg_def::{ @@ -10,9 +9,6 @@ use anoncreds_core::data_types::rev_reg_def::{ RegistryType }; use std::convert::TryFrom; -use std::convert::TryInto; -use serde::{Deserialize, Serialize}; -use serde_json::Result as SerdeResult; use std::sync::Arc; /// Wrapper for [RevocationRegistryDefinition] @@ -21,8 +17,8 @@ pub struct RevocationRegistryDefinition { } impl RevocationRegistryDefinition { - pub fn new(jsonString: String) -> Result { - let core_def: AnoncredsRevocationRegistryDefinition = serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsRevocationRegistryDefinition = serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; return Ok(RevocationRegistryDefinition { core: core_def }) } @@ -71,8 +67,8 @@ pub struct RevocationRegistryDefinitionPrivate { } impl RevocationRegistryDefinitionPrivate { - pub fn new(jsonString: String) -> Result { - let core_def: AnoncredsRevocationRegistryDefinitionPrivate = serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsRevocationRegistryDefinitionPrivate = serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; return Ok(RevocationRegistryDefinitionPrivate { core: core_def }) } @@ -101,8 +97,8 @@ pub struct RevocationRegistryDefinitionValue { } impl RevocationRegistryDefinitionValue { - pub fn new(jsonString: String) -> Result { - let core_def: AnoncredsRevocationRegistryDefinitionValue = serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsRevocationRegistryDefinitionValue = serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; return Ok(RevocationRegistryDefinitionValue { core: core_def }) } @@ -143,8 +139,8 @@ pub struct RevocationRegistryDefinitionValuePublicKeys { } impl RevocationRegistryDefinitionValuePublicKeys { - pub fn new(jsonString: String) -> Result { - let core_def: AnoncredsRevocationRegistryDefinitionValuePublicKeys = serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsRevocationRegistryDefinitionValuePublicKeys = serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; return Ok(RevocationRegistryDefinitionValuePublicKeys { core: core_def }) } diff --git a/uniffi/src/types/rev_status_list.rs b/uniffi/src/types/rev_status_list.rs index cf6347de..6574e096 100644 --- a/uniffi/src/types/rev_status_list.rs +++ b/uniffi/src/types/rev_status_list.rs @@ -1,16 +1,13 @@ use crate::types::error::AnoncredsError; -use anoncreds_core::data_types::rev_reg::RevocationRegistryId; use anoncreds_core::types::RevocationStatusList as AnoncredsRevocationStatusList; -use serde::{Deserialize, Serialize}; -use serde_json::Result as SerdeResult; pub struct RevocationStatusList { pub core: AnoncredsRevocationStatusList } impl RevocationStatusList { - pub fn new(jsonString: String) -> Result { - let core_def: AnoncredsRevocationStatusList = serde_json::from_str(&jsonString).map_err(|_| AnoncredsError::ConversionError)?; + pub fn new(json_string: String) -> Result { + let core_def: AnoncredsRevocationStatusList = serde_json::from_str(&json_string).map_err(|_| AnoncredsError::ConversionError)?; return Ok(RevocationStatusList { core: core_def }) } diff --git a/uniffi/src/verifier/mod.rs b/uniffi/src/verifier/mod.rs new file mode 100644 index 00000000..2e0180de --- /dev/null +++ b/uniffi/src/verifier/mod.rs @@ -0,0 +1,57 @@ +use crate::error::AnoncredsError; +use crate::presentation::{Presentation, PresentationRequest}; +use crate::CredentialDefinition; +use anoncreds_core::data_types::cred_def::CredentialDefinitionId; +use anoncreds_core::data_types::schema::{Schema, SchemaId}; +use anoncreds_core::verifier; +use std::collections::HashMap; +use std::sync::Arc; + +//https://mozilla.github.io/uniffi-rs/udl/builtin_types.html + +pub struct Verifier {} + +impl Verifier { + /// Create a new instance of [Verifier] + pub fn new() -> Self { + Verifier {} + } + + /// Verify an incoming proof presentation + pub fn verify_presentation( + &self, + presentation: Arc, + presentation_request: Arc, + schemas: HashMap, + credential_definitions: HashMap>, + // rev_reg_defs: Option< + // &HashMap<&RevocationRegistryDefinitionId, &RevocationRegistryDefinition>, + // >, + // rev_status_lists: Option>, + // nonrevoke_interval_override: Option< + // &HashMap<&RevocationRegistryDefinitionId, HashMap>, + // >, + ) -> Result { + let schemas_anoncreds = schemas.iter().map(|(k, v)| (k, v)).collect(); + let cred_defs = credential_definitions + .iter() + .map(|(k, v)| { + let tmp = &v.core; + (k, tmp) + }) + .collect(); + + let ret = verifier::verify_presentation( + &presentation.core, //&(*presentation_core).core + &presentation_request.core, + &schemas_anoncreds, + &cred_defs, + None, //TODO + None, //TODO + None, //TODO + ) + .map_err(|err| AnoncredsError::ProcessCredentialError(format!("Error: {}", err)))?; + + return Ok(ret); + } +}