public class CryptoJniNative extends Object
Constructor and Description |
---|
CryptoJniNative() |
Modifier and Type | Method and Description |
---|---|
static String |
computeCredentialDeploymentSignDigest(String input)
Computes the sign digest of a new credential deployment.
|
static String |
createIdentityRecoveryRequest(String input)
Creates an identity recovery request that is to be sent to an identity provider when
recovering a previously created identity.
|
static String |
createIdentityRequestV1(String input)
Creates an identity request that is to be sent to an identity provider when
creating a new identity.
|
static String |
createSecToPubTransfer(String input)
Creates a transfer from the encrypted amount to a public account payload, using the provided input string.
|
static String |
createUnsignedCredentialV1(String input)
Creates an unsigned credential.
|
static String |
createWeb3IdProof(String input)
Creates a web3Id presentation for the given statement.
|
static String |
generateBakerKeys()
Generates baker keys.
|
static String |
generateConfigureBakerKeysPayload(String input)
Generates a configure baker keys payload, using the provided input string.
|
static String |
generateEncryptedTransfer(String input)
Generates an encrypted transfer payload, using the provided input string.
|
static int |
generatePublicKey(byte[] secretKey,
byte[] buffer)
Generates the public key corresponding to the given secret key, and stores it in the provided buffer.
|
static int |
generateSecretKey(byte[] buffer)
Generates a new secret key and stores it in the provided buffer.
|
static String |
getAccountPublicKey(String seedAsHex,
Network network,
int identityProviderIndex,
int identityIndex,
int credentialCounter)
Derives an account public key from the provided seed and network for the given indices.
|
static String |
getAccountSigningKey(String seedAsHex,
Network network,
int identityProviderIndex,
int identityIndex,
int credentialCounter)
Derives an account signing key from the provided seed and network for the given indices.
|
static String |
getAttributeCommitmentRandomness(String seedAsHex,
Network network,
int identityProviderIndex,
int identityIndex,
int credentialCounter,
int attribute)
Derives the attribute commitment randomness for a specific attribute.
|
static String |
getCredentialId(String seedAsHex,
Network network,
int identityProviderIndex,
int identityIndex,
int credentialCounter,
String commitmentKey)
Gets the credential ID for a specific credential defined by the identity provider index,
identity index and the credential counter.
|
static String |
getIdCredSec(String seedAsHex,
Network network,
int identityProviderIndex,
int identityIndex)
Derives id cred sec from the provided seed and network for the given indices.
|
static String |
getPrfKey(String seedAsHex,
Network network,
int identityProviderIndex,
int identityIndex)
Derives a PRF-key from the provided seed and network for the given indices.
|
static String |
getSignatureBlindingRandomness(String seedAsHex,
Network network,
int identityProviderIndex,
int identityIndex)
Derives the signature blinding randomness for a specific identity.
|
static String |
getVerifiableCredentialBackupEncryptionKey(String seedAsHex,
Network network)
Derives the verifiable credential backup encryption key.
|
static String |
getVerifiableCredentialPublicKey(String seedAsHex,
Network network,
ContractAddress issuer,
int verifiableCredentialIndex)
Derives a verifiable credential public key.
|
static String |
getVerifiableCredentialSigningKey(String seedAsHex,
Network network,
ContractAddress issuer,
int verifiableCredentialIndex)
Derives a verifiable credential signing key.
|
static String |
isAcceptableAtomicStatement(String input,
String rangeTags,
String setTags,
AcceptableRequest.RawAttributeCheck check)
Check that an atomic is acceptable, with the given restrictions
|
static String |
isAcceptableRequest(String input)
Check that a request is acceptable
|
static String |
serializeCredentialDeploymentForSubmission(String input)
Serializes a credential deployment for submission, i.e.
|
static String |
serializeInitParameter(SchemaParameter parameter,
InitName initName,
byte[] schemaBytes,
SchemaVersion schemaVersion,
boolean verboseErrors)
Serializes a parameter for an init function using a schema of the module.
|
static String |
serializeReceiveParameter(SchemaParameter parameter,
ReceiveName receiveName,
byte[] schemaBytes,
SchemaVersion schemaVersion,
boolean verboseErrors)
Serializes a parameter for a receive function using a schema of the module.
|
static int |
sign(byte[] privateKey,
byte[] message,
byte[] out)
Signs a message using the provided private key.
|
static int |
verify(byte[] publicKey,
byte[] message,
byte[] signature)
Verifies a signature for a message using the provided public key.
|
public static int sign(byte[] privateKey, byte[] message, byte[] out)
privateKey
- The private key to use for signing.message
- The message to sign.out
- The buffer to write the signature to.public static int verify(byte[] publicKey, byte[] message, byte[] signature)
publicKey
- The public key to use for verification.message
- The message to verify the signature for.signature
- The signature to verify.public static int generateSecretKey(byte[] buffer)
buffer
- The buffer to write the secret key to.public static int generatePublicKey(byte[] secretKey, byte[] buffer)
secretKey
- The secret key to generate the public key for.buffer
- The buffer to write the public key to.public static String createSecToPubTransfer(String input)
input
- The input string to use for creating the transfer.public static String generateEncryptedTransfer(String input)
input
- The input string to use for generating the encrypted transfer.public static String generateBakerKeys()
public static String generateConfigureBakerKeysPayload(String input)
input
- The input string to use for generating the configure baker keys payload.public static String serializeReceiveParameter(SchemaParameter parameter, ReceiveName receiveName, byte[] schemaBytes, SchemaVersion schemaVersion, boolean verboseErrors)
parameter
- the parameter.receiveName
- the name of the contract and the method.schemaBytes
- schema of the contract.schemaVersion
- version of the schema.verboseErrors
- whether errors are returned in verbose format or not, can be useful when debugging why serialization fails.SerializeParameterResult
. If the serialization was successful, the field 'serializedParameter' contains the serialized parameter as hex encoded bytes.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String serializeInitParameter(SchemaParameter parameter, InitName initName, byte[] schemaBytes, SchemaVersion schemaVersion, boolean verboseErrors)
parameter
- the parameter.initName
- name of the contract.schemaBytes
- schema of the contract.schemaVersion
- version of the schema.verboseErrors
- whether errors are returned in verbose format or not, can be useful when debugging why serialization fails.SerializeParameterResult
. If the serialization was successful, the field 'serializedParameter' contains the serialized parameter as hex encoded bytes.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getAccountSigningKey(String seedAsHex, Network network, int identityProviderIndex, int identityIndex, int credentialCounter)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived key is foridentityProviderIndex
- the index of the identity provider that the account is associated with interpreted as a u32.identityIndex
- the index of the identity that the account is associated with interpreted as a u32.credentialCounter
- the number of the credential interpreted as a u32.StringResult
. If successful the field 'result' contains the hex encoded account signing key.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getAccountPublicKey(String seedAsHex, Network network, int identityProviderIndex, int identityIndex, int credentialCounter)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived key is foridentityProviderIndex
- the index of the identity provider that the account is associated with interpreted as a u32.identityIndex
- the index of the identity that the account is associated with interpreted as a u32.credentialCounter
- the number of the credential interpreted as a u32.StringResult
. If successful the field 'result' contains the hex encoded account public key.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getIdCredSec(String seedAsHex, Network network, int identityProviderIndex, int identityIndex)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived key is foridentityProviderIndex
- the index of the identity provider that the account is associated with interpreted as a u32.identityIndex
- the index of the identity that the account is associated with interpreted as a u32.StringResult
. If successful the field 'result' contains the hex id cred sec.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getPrfKey(String seedAsHex, Network network, int identityProviderIndex, int identityIndex)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived key is foridentityProviderIndex
- the index of the identity provider that the account is associated with interpreted as a u32.identityIndex
- the index of the identity that the account is associated with interpreted as a u32.StringResult
. If successful the field 'result' contains the hex encoded PRF-key.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getCredentialId(String seedAsHex, Network network, int identityProviderIndex, int identityIndex, int credentialCounter, String commitmentKey)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived key is foridentityProviderIndex
- the index of the identity provider that the account is associated with interpreted as a u32.identityIndex
- the index of the identity that the account is associated with interpreted as a u32.credentialCounter
- the credential number of the credential to get the id for interpreted as a u8.commitmentKey
- the on chain commitment key. This value can be retrieved from a node through its gRPC interface.StringResult
. If successful the field 'result' contains the hex encoded credential id.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getSignatureBlindingRandomness(String seedAsHex, Network network, int identityProviderIndex, int identityIndex)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived randomness is foridentityProviderIndex
- the index of the identity provider interpreted as a u32.identityIndex
- the index of the identity interpreted as a u32.StringResult
. If successful the field 'result' contains the hex encoded signature blinding randomness.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getAttributeCommitmentRandomness(String seedAsHex, Network network, int identityProviderIndex, int identityIndex, int credentialCounter, int attribute)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived randomness is foridentityProviderIndex
- the index of the identity provider interpreted as a u32.identityIndex
- the index of the identity interpreted as a u32.credentialCounter
- the credential number that the attribute is randomness is for interpreted as a u32.attribute
- the attribute key index interpreted as a u8.StringResult
. If successful the field 'result' contains the hex encoded attribute commitment randomness.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getVerifiableCredentialSigningKey(String seedAsHex, Network network, ContractAddress issuer, int verifiableCredentialIndex)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived randomness is forissuer
- the verifiable credential issuer contractverifiableCredentialIndex
- the index of the verifiable credential to derive a signing key for interpreted as a u32StringResult
. If successful the field 'result' contains the hex encoded verifiable credential signing key.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getVerifiableCredentialPublicKey(String seedAsHex, Network network, ContractAddress issuer, int verifiableCredentialIndex)
seedAsHex
- the seed derived from a seed phrase as a hex stringnetwork
- the network that the derived randomness is forissuer
- the verifiable credential issuer contractverifiableCredentialIndex
- the index of the verifiable credential to derive a public key for interpreted as a u32StringResult
. If successful the field 'result' contains the hex encoded verifiable credential public key.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String getVerifiableCredentialBackupEncryptionKey(String seedAsHex, Network network)
StringResult
. If successful the field 'result' contains the hex encoded verifiable credential backup encryption key.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String createIdentityRequestV1(String input)
input
- IdentityRequestInput
serialized as JSONStringResult
. If successful the field 'result' contains the identity request as JSON.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String createIdentityRecoveryRequest(String input)
input
- IdentityRecoveryRequestInput
serialized as JSONStringResult
. If successful the field 'result' contains the identity recovery request as JSON.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String createUnsignedCredentialV1(String input)
input
- UnsignedCredentialInput
serialized as JSON.StringResult
. If successful the field 'result' contains the unsigned credential as JSON.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String computeCredentialDeploymentSignDigest(String input)
input
- CredentialDeploymentDetails
serialized as JSON.StringResult
. If successful the field 'result' contains the sign digest of
CredentialDeploymentDetails
as a hex encoded string.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String serializeCredentialDeploymentForSubmission(String input)
input
- CredentialDeploymentSerializationContext
serialized as JSON.StringResult
. If successful the field 'result' contains the serialization of
CredentialDeploymentSerializationContext
as a hex encoded string.
If not successful, the 'err' field contains a JNIError
detailing what went wrong.public static String createWeb3IdProof(String input)
input
- Web3IdProofInput
serialized as JSON.StringResult
. If successful the field 'result' contains the
Web3IdProof
as JSON.public static String isAcceptableRequest(String input)
input
- Request
serialized as JSON.VoidResult
. If successful the field
'result' is empty,
but if not acceptable the reason will be contained in the error.public static String isAcceptableAtomicStatement(String input, String rangeTags, String setTags, AcceptableRequest.RawAttributeCheck check)
input
- Request
serialized as JSON.rangeTags
- the list of tags, which may be used for range statements,
serialized as JSON.setTags
- the list of tags, which may be used for membership
statements, serialized as JSON.check
- provides the function to check whether the statement value
is acceptable.VoidResult
. If successful the field
'result' is empty,
but if not acceptable the reason will be contained in the error.Copyright © 2025. All rights reserved.