-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move bec32 constants to own file and add defs for asset encoding
import bool Add asset encoding api
- Loading branch information
Showing
5 changed files
with
76 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Common BECH32m constants | ||
#define CHECKSUM_LENGTH 8 | ||
#define BECH32_BITS_PER_CHAR 5 | ||
#define BITS_PER_BYTE 8 | ||
#define BECH32_SEPARATOR "1" | ||
#define SEPARATOR_LENGTH 1 | ||
|
||
// Some defines for address and asset encoding | ||
#define ADDR_BECH32_PREFIX "penumbra" BECH32_SEPARATOR | ||
// #define FIXED_ADDR_PREFIX ADDR_BECH32_PREFIX BECH32_SEPARATOR | ||
#define ASSET_BECH32_PREFIX "passet" BECH32_SEPARATOR | ||
#define ASSET_ID_LEN 32 | ||
// HRP length + 1 (separator) + 52 (data) + 6 (checksum) + 1 (null terminator) | ||
// 6 + 1 + 52 + 6 + 1 = 66 | ||
#define ENCODED_ASSET_SIZE (strlen(ASSET_BECH32_PREFIX) + ((ASSET_ID_LEN * BITS_PER_BYTE + BECH32_BITS_PER_CHAR - 1) / BECH32_BITS_PER_CHAR) + CHECKSUM_LENGTH + 1) | ||
|
||
#define ADDR_HRP_LENGTH (sizeof(ADDR_BECH32_PREFIX) - 1) | ||
|
||
#define ENCODED_DATA_LENGTH \ | ||
(((ADDRESS_LEN_BYTES + CHECKSUM_LENGTH) * BITS_PER_BYTE + BECH32_BITS_PER_CHAR - 1) / BECH32_BITS_PER_CHAR) | ||
|
||
#define ENCODED_ADDR_LEN (ADDR_HRP_LENGTH + SEPARATOR_LENGTH + ENCODED_DATA_LENGTH) | ||
|
||
#define ENCODED_ADDR_BUFFER_SIZE (ENCODED_ADDR_LEN + 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters