Methods
# asset_type_from_jsvalue() → {string}
Generates asset type as a Base64 string from a JSON-serialized JavaScript value.
# build_id() → {string}
Returns the git commit hash and commit date of the commit this library was built against.
# create_credential(issuer_public_key, signature, attributes) → {Credential}
Generates a signature on user attributes that can be used to create a credential.
Parameters:
Name | Type | Description |
---|---|---|
issuer_public_key |
CredIssuerPublicKey | Public key of credential issuer. |
signature |
CredentialSignature | Credential issuer signature on attributes. |
attributes |
JsValue | Array of attribute assignments of the form `[{name: "credit_score", val: "760"}]'. |
# get_priv_key_str() → {string}
Extracts the private key as a string from a transfer key pair.
# keypair_from_str() → {XfrKeyPair}
Constructs a transfer key pair from a hex-encoded string.
The encode a key pair, use keypair_to_str
function.
# keypair_to_str() → {string}
Expresses a transfer key pair as a hex-encoded string.
To decode the string, use keypair_from_str
function.
# new_keypair() → {XfrKeyPair}
Creates a new transfer key pair.
# new_keypair_from_seed(name) → {XfrKeyPair}
Generates a new keypair deterministically from a seed string and an optional name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | undefined |
# open_client_asset_record(record, owner_memo, keypair, owner_memo) → {any}
Returns a JavaScript object containing decrypted owner record information,
where amount
is the decrypted asset amount, and asset_type
is the decrypted asset type code.
Parameters:
Name | Type | Description |
---|---|---|
record |
ClientAssetRecord | Owner record. |
owner_memo |
OwnerMemo | Owner memo of the associated record. |
keypair |
XfrKeyPair | Keypair of asset owner. |
owner_memo |
OwnerMemo | undefined |
- See:
-
- ClientAssetRecord.from_json_record for information about how to construct an asset record object from a JSON result returned from the ledger server.
# public_key_from_base64() → {XfrPublicKey}
Converts a base64 encoded public key string to a public key.
# public_key_to_base64() → {string}
Returns base64 encoded representation of an XfrPublicKey.
# random_asset_type() → {string}
Generates random Base64 encoded asset type as a Base64 string. Used in asset definitions.
- See:
-
- add_operation_create_asset for instructions on how to define an asset with a new asset type
# trace_assets(xfr_body, tracer_keypair, candidate_assets) → {any}
Returns information about traceable assets for a given transfer.
Parameters:
Name | Type | Description |
---|---|---|
xfr_body |
JsValue | JSON of a transfer note from a transfer operation. |
tracer_keypair |
AssetTracerKeyPair | Asset tracer keypair. |
candidate_assets |
JsValue | List of asset types traced by the tracer keypair. |
# verify_authenticated_custom_data_result(state_commitment, authenticated_txn) → {boolean}
Given a serialized state commitment and an authenticated custom data result, returns true if the custom data result correctly hashes up to the state commitment and false otherwise.
Parameters:
Name | Type | Description |
---|---|---|
state_commitment |
string | String representing the state commitment. |
authenticated_txn |
JsValue | JSON-encoded value representing the authenticated custom data result. |
Will throw an error if the state commitment or the authenticated result fail to deserialize.
# verify_authenticated_txn(state_commitment, authenticated_txn) → {boolean}
Given a serialized state commitment and transaction, returns true if the transaction correctly hashes up to the state commitment and false otherwise.
Parameters:
Name | Type | Description |
---|---|---|
state_commitment |
string | String representing the state commitment. |
authenticated_txn |
string | String representing the transaction. |
- See:
-
- Network.getTxn for instructions on fetching a transaction from the ledger.
- Network.getStateCommitment for instructions on fetching a ledger state commitment.
Will throw an error if the state commitment or the transaction fails to deserialize.
# wasm_credential_commit(user_secret_key, user_public_key, credential) → {CredentialCommitmentData}
Generates a credential commitment. A credential commitment can be used to selectively reveal attribute assignments.
Parameters:
Name | Type | Description |
---|---|---|
user_secret_key |
CredUserSecretKey | Secret key of credential user. |
user_public_key |
XfrPublicKey | Ledger signing key to link this credential to. |
credential |
Credential | Credential object. |
# wasm_credential_issuer_key_gen(attributes) → {CredentialIssuerKeyPair}
Generates a new credential issuer key.
Parameters:
Name | Type | Description |
---|---|---|
attributes |
JsValue | Array of attribute types of the form |
# wasm_credential_open_commitment(user_secret_key, credential, reveal_fields) → {CredentialPoK}
Generates a new reveal proof from a credential commitment key.
Parameters:
Name | Type | Description |
---|---|---|
user_secret_key |
CredUserSecretKey | Secret key of the credential user who owns the credentials. |
credential |
Credential | Credential whose attributes will be revealed. |
reveal_fields |
JsValue | Array of strings representing attribute fields to reveal. |
Will throw an error if a reveal proof cannot be generated from the credential
or reveal_fields
fails to deserialize.
# wasm_credential_reveal(user_sk, credential, reveal_fields) → {CredentialRevealSig}
Selectively reveals attributes committed to in a credential commitment
Parameters:
Name | Type | Description |
---|---|---|
user_sk |
CredUserSecretKey | Secret key of credential user. |
credential |
Credential | Credential object. |
reveal_fields |
JsValue | Array of string names representing credentials to reveal (i.e.
|
# wasm_credential_sign(issuer_secret_key, user_public_key, attributes) → {CredentialSignature}
Generates a signature on user attributes that can be used to create a credential.
Parameters:
Name | Type | Description |
---|---|---|
issuer_secret_key |
CredIssuerSecretKey | Secret key of credential issuer. |
user_public_key |
CredUserPublicKey | Public key of credential user. |
attributes |
JsValue | Array of attribute assignments of the form |
Will throw an error if the signature cannot be generated.
# wasm_credential_user_key_gen(issuer_pub_key) → {CredentialUserKeyPair}
Generates a new credential user key.
Parameters:
Name | Type | Description |
---|---|---|
issuer_pub_key |
CredIssuerPublicKey | The credential issuer that can sign off on this user's attributes. |
# wasm_credential_verify(issuer_pub_key, attributes, commitment, pok)
Verifies revealed attributes from a commitment.
Parameters:
Name | Type | Description |
---|---|---|
issuer_pub_key |
CredIssuerPublicKey | Public key of credential issuer. |
attributes |
JsValue | Array of attribute assignments to check of the form |
commitment |
CredentialCommitment | Commitment to the credential. |
pok |
CredentialPoK | Proof that the credential commitment is valid and commits to the attribute values being revealed. |
# wasm_credential_verify_commitment(issuer_pub_key, Credential, Proof, Ledger)
Verifies a credential commitment. Used to confirm that a credential is tied to a ledger address.
Parameters:
Name | Type | Description |
---|---|---|
issuer_pub_key |
CredIssuerPublicKey | The credential issuer that has attested to the credentials that have been committed to. |
Credential |
CredentialCommitment | commitment |
Proof |
CredPoK | of knowledge of the underlying commitment |
Ledger |
XfrPublicKey | address linked to this credential commitment. |
Will throw an error during verification failure (i.e. the supplied ledger address is incorrect, the commitment is tied to a different credential issuer, or the proof of knowledge is invalid, etc.)