@ledgerhq/concordium-core
v0.4.0
Published
Shared Concordium protocol types, serialization, and utilities
Maintainers
Keywords
Readme
@ledgerhq/concordium-core
Shared Concordium protocol types, serialization, and utilities used by both @ledgerhq/hw-app-concordium and @ledgerhq/coin-concordium.
Purpose
This package extracts shared protocol-level logic so that the hardware wallet app and the coin module can depend on it independently, without the coin module depending on the hardware wallet app.
hw-app-concordium ←── @ledgerhq/concordium-core ──→ coin-concordiumExported APIs
Types (src/types.ts)
SchemeId— Ed25519 cryptographic scheme identifierTransactionType— Transaction type discriminators (Transfer, TransferWithMemo)Transaction— Transaction structure for signingTransferPayload— Simple transfer payloadTransferWithMemoPayload— Transfer with memo payloadTransactionPayload— Union of transfer payload typesCredentialDeploymentTransaction— Credential deployment in hw-app formatIdOwnershipProofs— ID ownership proofs from Concordium ID AppAddress— Address response from deviceVerifyAddressResponse— Verify address response from deviceSigningResult— Signing result with signature and serialized transaction
Address (src/address.ts)
AccountAddress— Concordium account address with Base58 ↔ Buffer conversionAccountAddress.fromBase58(address: string): AccountAddress— Parse Base58Check addressAccountAddress.isValid(address: string): boolean— Check if a string is a valid Concordium addresstoBase58(): string— Convert to Base58Check stringtoBuffer(): Buffer— Get raw 32-byte address buffer
CBOR (src/cbor.ts)
encodeMemoToCbor(memo: string): Buffer— Encode memo string to CBOR text stringmemoEncodedSize(memo: string): number— CBOR-encoded byte length without allocating (useful for size checks before encoding)decodeMemoFromCbor(cborEncoded: Buffer): string— Decode CBOR-encoded memoMAX_MEMO_LENGTH— Maximum memo length before CBOR encoding (254 bytes)MAX_CBOR_SIZE— Maximum CBOR-encoded memo size (256 bytes)
Utils (src/utils.ts)
encodeWord8/16/32/64— Encode integers to Buffer (big/little endian)decodeWord16/32/64— Decode integers from BufferencodeWord8FromString— Encode a string-represented number as Word8serializeMap— Serialize a Record to binary formatserializeVerifyKey— Serialize a public key with scheme prefixserializeYearMonth— Serialize YYYYMM date stringserializePath— Serialize BIP32 path array to BufferpathToBuffer— Convert BIP32 path string to device-compatible BufferchunkBuffer— Split a buffer into fixed-size chunks
Serialization (src/serialization.ts)
serializeTransfer(tx): Buffer— Serialize a Transfer transactionserializeTransferWithMemo(tx): Buffer— Serialize a TransferWithMemo transactionserializeTransaction(tx): Buffer— Serialize any supported transaction typedeserializeTransfer(buffer): Transaction— Deserialize Transfer from bufferdeserializeTransferWithMemo(buffer): Transaction— Deserialize TransferWithMemo from bufferdeserializeTransaction(buffer): Transaction— Deserialize any transaction by auto-detecting typegetTransactionType(buffer): TransactionType— Get transaction type from serialized bufferserializeCredentialDeploymentValues(payload): Buffer— Serialize credential deployment valuesserializeIdOwnershipProofs(proofs): Buffer— Serialize ID ownership proofsserializeAccountOwnershipProofs(signatures): Buffer— Serialize account ownership proofsinsertAccountOwnershipProofs(idProofs, accountSig): string— Combine ID + account proofs
Related Packages
@ledgerhq/hw-app-concordium— Ledger device communication for Concordium (depends on this package for shared types/serialization; adds APDU-specific functions)@ledgerhq/coin-concordium— Ledger Live coin module for Concordium (depends on this package for shared types/serialization)
