Skip to main content
Last updated

Commitments

decrypt-cc20p1305

Use decrypt-cc20p1305 to perform decryption of a CIPHERTEXT using the CHACHA20-POLY1305 Authenticated Encryption with Associated Data (AEAD) construction described in IETF RFC 7539.

Basic syntax

To perform decryption of a CIPHERTEXT using CHACHA20-POLY1305, use the following syntax:

(decrypt-cc20p1305 CIPHERTEXT NONCE AAD MAC PUBLIC-KEY SECRET-KEY)

Arguments

Use the following arguments to specify the inputs for the decrypt-cc20p1305 Pact function:

ArgumentTypeDescription
ciphertextstringSpecifies the ciphertext to decrypt (unpadded base64url).
noncestringSpecifies the 12-byte nonce used in the encryption (base64).
aadstringSpecifies the additional authentication data (AAD) (base64).
macstringSpecifies the "detached" base64 tag value for authentication.
public-keystringSpecifies the base-16 Curve25519 public key.
secret-keystringSpecifies the base-16 Curve25519 secret key.

Return values

The decrypt-cc20p1305 function returns the decrypted plaintext as an unpadded base64URL string.

Example

The following example demonstrates the decrypt-cc20p1305 function:

pact
(decrypt-cc20p1305 "aGVsbG8gd29ybGQh" "jXg5EEna3ncA" "QW5kcm9pZCBBdXRob3JpemF0aW9uIERhdGE" "yzNz8N5cc0ZT4vp_zV-6PmfYvgEtZhhlS8_JZ6odS0A" "A9Fp8OL3Mgu_8haIjy8JhsmLzPmzJ0JcbE9kSVNB5Y" "MwYTMzc2NjVhZGFmY2QxMzM4Y2I1ZmU2ZDM1YjQ3MzU") 
pact
(decrypt-cc20p1305 "aGVsbG8gd29ybGQh" "jXg5EEna3ncA" "QW5kcm9pZCBBdXRob3JpemF0aW9uIERhdGE" "yzNz8N5cc0ZT4vp_zV-6PmfYvgEtZhhlS8_JZ6odS0A" "A9Fp8OL3Mgu_8haIjy8JhsmLzPmzJ0JcbE9kSVNB5Y" "MwYTMzc2NjVhZGFmY2QxMzM4Y2I1ZmU2ZDM1YjQ3MzU") 

In this example, decrypt-cc20p1305 is used to decrypt the ciphertext "aGVsbG8gd29ybGQh" using CHACHA20-POLY1305 with the specified nonce, additional authentication data (AAD), authentication tag (MAC), public key, and secret key. The function returns the decrypted plaintext as an unpadded base64URL string.

hyperlane-decode-token-message

Use hyperlane-decode-token-message to decode a base-64-unpadded encoded Hyperlane Token Message into an object containing recipient, amount, and chainId information.

Basic syntax

To decode a Hyperlane Token Message using hyperlane-decode-token-message, use the following syntax:

pact
(hyperlane-decode-token-message x)
pact
(hyperlane-decode-token-message x)

Arguments

NameTypeDescription
xstringA base-64-unpadded encoded Hyperlane Token Message

Return value

The hyperlane-decode-token-message function returns an object with the following fields:

FieldTypeDescription
recipientGUARDThe recipient of the token message
amountDECIMALThe amount of tokens
chainIdSTRINGThe chain identifier

Examples

Here's an example of using hyperlane-decode-token-message to decode a Hyperlane Token Message:

pact
pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0"){"amount": 0.000000000000000123,"chainId": "4","recipient": KeySet {keys: [da1a339bd82d2c2e9180626a00dc043275deb3ababb27b5738abf6b9dcee8db6],pred: keys-all}}
pact
pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0"){"amount": 0.000000000000000123,"chainId": "4","recipient": KeySet {keys: [da1a339bd82d2c2e9180626a00dc043275deb3ababb27b5738abf6b9dcee8db6],pred: keys-all}}

In this example, the function decodes the provided base-64-unpadded string and returns an object containing the decoded information:

  • The amount is 0.000000000000000123
  • The chainId is "4"
  • The recipient is a KeySet with one key and a keys-all predicate

hyperlane-encode-token-message

Use hyperlane-encode-token-message to encode an object into a Hyperlane Token message as an unpadded base64url string.

Basic syntax

To encode an object into a Hyperlane Token message using hyperlane-encode-token-message, use the following syntax:

pact
(hyperlane-encode-token-message x)
pact
(hyperlane-encode-token-message x)

Arguments

NameTypeDescription
xobjectAn object containing recipient, amount, and chainId

The object should have the following structure:

  • recipient: string (base64 encoded representation of a guard)
  • amount: decimal
  • chainId: string

Return value

The hyperlane-encode-token-message function returns a string representing the encoded Hyperlane Token message in unpadded base64url format.

Examples

Here's an example of using hyperlane-encode-token-message to encode an object into a Hyperlane Token message:

pact
pact> (hyperlane-encode-token-message {"recipient": "eyJwcmVkIjogImtleXMtYWxsIiwgImtleXMiOlsiZGExYTMzOWJkODJkMmMyZTkxODA2MjZhMDBkYzA0MzI3NWRlYjNhYmFiYjI3YjU3MzhhYmY2YjlkY2VlOGRiNiJdfQ", "amount":123000000000000000.0, "chainId":"4"})"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbT72StfgAAABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0"
pact
pact> (hyperlane-encode-token-message {"recipient": "eyJwcmVkIjogImtleXMtYWxsIiwgImtleXMiOlsiZGExYTMzOWJkODJkMmMyZTkxODA2MjZhMDBkYzA0MzI3NWRlYjNhYmFiYjI3YjU3MzhhYmY2YjlkY2VlOGRiNiJdfQ", "amount":123000000000000000.0, "chainId":"4"})"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbT72StfgAAABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0"

In this example, the function encodes the provided object into a Hyperlane Token message. The object contains:

  • A recipient represented as a base64 encoded string (which itself represents a guard)
  • An amount of 123000000000000000.0
  • A chainId of "4"

The function returns the encoded message as an unpadded base64url string.

hyperlane-message-id

Use hyperlane-message-id to get the Message Id of a Hyperlane Message object.

Basic syntax

To get the Message Id of a Hyperlane Message object using hyperlane-message-id, use the following syntax:

pact
(hyperlane-message-id x)
pact
(hyperlane-message-id x)

Arguments

NameTypeDescription
xobject:*A Hyperlane Message object

The Hyperlane Message object should have the following structure:

  • destinationDomain: integer
  • nonce: integer
  • originDomain: integer
  • recipient: integer
  • sender: string
  • messageBody: string
  • version: integer

Return value

The hyperlane-message-id function returns a string representing the Message Id of the given Hyperlane Message object.

Examples

Here's an example of using hyperlane-message-id to get the Message Id of a Hyperlane Message object:

pact
pact> (hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU","sender": "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY","messageBody": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0","version": 1})"9lxextceVw0b18kUdfwSze-3Iw7OE-Z5Kq9I8HTDKGE"
pact
pact> (hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU","sender": "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY","messageBody": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0","version": 1})"9lxextceVw0b18kUdfwSze-3Iw7OE-Z5Kq9I8HTDKGE"

In this example, the function takes a Hyperlane Message object with the following properties:

  • destinationDomain: 1
  • nonce: 325
  • originDomain: 626
  • recipient: "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU"
  • sender: "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY"
  • messageBody: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0"
  • version: 1

The function returns the Message Id "9lxextceVw0b18kUdfwSze-3Iw7OE-Z5Kq9I8HTDKGE" for this Hyperlane Message object.

validate-keypair

Use validate-keypair to verify that the Curve25519 public key and secret key you specify are base-16 strings of 32 characters match each other.

Basic syntax

To validate a Curve25519 public and secret key pair, use the following syntax:

pact
(validate-keypair public secret)
pact
(validate-keypair public secret)

Arguments

Use the following arguments to specify the public key and the secret key that you want to validate using the validate-keypair Pact function.

ArgumentTypeDescription
publicstringSpecifies the public key as a base-16 string with a length of 32 characters.
secretstringSpecifies the secret key as a base-16 string with a length of 32 characters.

Return value

The validate-keypair function returns a boolean value indicating whether the provided key pair matches.

Examples

The following example demonstrates how to use the validate-keypair function to verify that the Curve25519 key pair composed of the public key public-key and the secret key secret-key match:

pact
(validate-keypair public-key secret-key)true
pact
(validate-keypair public-key secret-key)true