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:
| Argument | Type | Description | 
|---|---|---|
| ciphertext | string | Specifies the ciphertext to decrypt (unpadded base64url). | 
| nonce | string | Specifies the 12-byte nonce used in the encryption (base64). | 
| aad | string | Specifies the additional authentication data (AAD) (base64). | 
| mac | string | Specifies the "detached" base64 tag value for authentication. | 
| public-key | string | Specifies the base-16 Curve25519 public key. | 
| secret-key | string | Specifies 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:
(decrypt-cc20p1305 "aGVsbG8gd29ybGQh" "jXg5EEna3ncA" "QW5kcm9pZCBBdXRob3JpemF0aW9uIERhdGE" "yzNz8N5cc0ZT4vp_zV-6PmfYvgEtZhhlS8_JZ6odS0A" "A9Fp8OL3Mgu_8haIjy8JhsmLzPmzJ0JcbE9kSVNB5Y" "MwYTMzc2NjVhZGFmY2QxMzM4Y2I1ZmU2ZDM1YjQ3MzU") (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:
(hyperlane-decode-token-message x)(hyperlane-decode-token-message x)Arguments
| Name | Type | Description | 
|---|---|---|
| x | string | A base-64-unpadded encoded Hyperlane Token Message | 
Return value
The hyperlane-decode-token-message function returns an object with the following fields:
| Field | Type | Description | 
|---|---|---|
| recipient | GUARD | The recipient of the token message | 
| amount | DECIMAL | The amount of tokens | 
| chainId | STRING | The chain identifier | 
Examples
Here's an example of using hyperlane-decode-token-message to decode a Hyperlane Token Message:
pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0"){"amount": 0.000000000000000123,"chainId": "4","recipient": KeySet {keys: [da1a339bd82d2c2e9180626a00dc043275deb3ababb27b5738abf6b9dcee8db6],pred: keys-all}}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 amountis 0.000000000000000123
- The chainIdis "4"
- The recipientis a KeySet with one key and akeys-allpredicate
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:
(hyperlane-encode-token-message x)(hyperlane-encode-token-message x)Arguments
| Name | Type | Description | 
|---|---|---|
| x | object | An object containing recipient,amount, andchainId | 
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> (hyperlane-encode-token-message {"recipient": "eyJwcmVkIjogImtleXMtYWxsIiwgImtleXMiOlsiZGExYTMzOWJkODJkMmMyZTkxODA2MjZhMDBkYzA0MzI3NWRlYjNhYmFiYjI3YjU3MzhhYmY2YjlkY2VlOGRiNiJdfQ", "amount":123000000000000000.0, "chainId":"4"})"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbT72StfgAAABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0"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 recipientrepresented as a base64 encoded string (which itself represents a guard)
- An amountof 123000000000000000.0
- A chainIdof "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:
(hyperlane-message-id x)(hyperlane-message-id x)Arguments
| Name | Type | Description | 
|---|---|---|
| x | object:* | 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> (hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "AAAAAAAAAADpgrOqkM0BOY-FQnNzkDXuYlsVcf50GRU","sender": "AAAAAAAAAAAAAAAAf6k4W-ECrD6sKXSD3WIz1is-FJY","messageBody": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHsABHsicHJlZCI6ICJrZXlzLWFsbCIsICJrZXlzIjpbImRhMWEzMzliZDgyZDJjMmU5MTgwNjI2YTAwZGMwNDMyNzVkZWIzYWJhYmIyN2I1NzM4YWJmNmI5ZGNlZThkYjYiXX0","version": 1})"9lxextceVw0b18kUdfwSze-3Iw7OE-Z5Kq9I8HTDKGE"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:
(validate-keypair public secret)(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.
| Argument | Type | Description | 
|---|---|---|
| public | string | Specifies the public key as a base-16 string with a length of 32 characters. | 
| secret | string | Specifies 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:
(validate-keypair public-key secret-key)true(validate-keypair public-key secret-key)true