Title

Global

Methods

# asset_type_from_jsvalue() → {string}

Generates asset type as a Base64 string from a JSON-serialized JavaScript value.

View Source pkg/wasm.js, line 141

string

# build_id() → {string}

Returns the git commit hash and commit date of the commit this library was built against.

View Source pkg/wasm.js, line 100

string

# 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"}]'.

View Source pkg/wasm.js, line 610

Credential

# get_priv_key_str() → {string}

Extracts the private key as a string from a transfer key pair.

View Source pkg/wasm.js, line 402

string

# get_pub_key_str() → {string}

Extracts the public key as a string from a transfer key pair.

View Source pkg/wasm.js, line 382

string

# keypair_from_str() → {XfrKeyPair}

Constructs a transfer key pair from a hex-encoded string. The encode a key pair, use keypair_to_str function.

View Source pkg/wasm.js, line 500

XfrKeyPair

# keypair_to_str() → {string}

Expresses a transfer key pair as a hex-encoded string. To decode the string, use keypair_from_str function.

View Source pkg/wasm.js, line 479

string

# new_keypair() → {XfrKeyPair}

Creates a new transfer key pair.

View Source pkg/wasm.js, line 421

XfrKeyPair

# 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

View Source pkg/wasm.js, line 432

XfrKeyPair

# 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.

View Source pkg/wasm.js, line 364

any

# public_key_from_base64() → {XfrPublicKey}

Converts a base64 encoded public key string to a public key.

View Source pkg/wasm.js, line 466

XfrPublicKey

# public_key_to_base64() → {string}

Returns base64 encoded representation of an XfrPublicKey.

View Source pkg/wasm.js, line 446

string

# 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

View Source pkg/wasm.js, line 122

string

# 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.

View Source pkg/wasm.js, line 688

any

# 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.

View Source pkg/wasm.js, line 189

Will throw an error if the state commitment or the authenticated result fail to deserialize.

boolean

# 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.

View Source pkg/wasm.js, line 169

Will throw an error if the state commitment or the transaction fails to deserialize.

boolean

# 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.

View Source pkg/wasm.js, line 632

# 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 [{name: "credit_score", size: 3}]. The size refers to byte-size of the credential. In this case, the "credit_score" attribute is represented as a 3 byte string "760". attributes is the list of attribute types that the issuer can sign off on.

View Source pkg/wasm.js, line 516

# 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.

View Source pkg/wasm.js, line 559

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. ["credit_score"]).

View Source pkg/wasm.js, line 651

# 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 [{name: "credit_score", val: "760"}].

View Source pkg/wasm.js, line 592

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.

View Source pkg/wasm.js, line 574

# 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 [{name: "credit_score", val: "760"}].

commitment CredentialCommitment

Commitment to the credential.

pok CredentialPoK

Proof that the credential commitment is valid and commits to the attribute values being revealed.

View Source pkg/wasm.js, line 671

# 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.

View Source pkg/wasm.js, line 537

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.)