@ottochain/sdk 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +305 -0
- package/dist/apps/contracts/index.d.ts +21 -0
- package/dist/apps/contracts/index.js +39 -0
- package/dist/apps/contracts/types.d.ts +24 -0
- package/dist/apps/contracts/types.js +48 -0
- package/dist/apps/identity/index.d.ts +22 -0
- package/dist/apps/identity/index.js +40 -0
- package/dist/apps/identity/types.d.ts +30 -0
- package/dist/apps/identity/types.js +53 -0
- package/dist/apps/index.d.ts +29 -0
- package/dist/apps/index.js +60 -0
- package/dist/apps/markets/index.d.ts +26 -0
- package/dist/apps/markets/index.js +46 -0
- package/dist/apps/markets/types.d.ts +185 -0
- package/dist/apps/markets/types.js +252 -0
- package/dist/apps/oracles/index.d.ts +26 -0
- package/dist/apps/oracles/index.js +46 -0
- package/dist/apps/oracles/types.d.ts +211 -0
- package/dist/apps/oracles/types.js +306 -0
- package/dist/cjs/apps/contracts/index.js +60 -0
- package/dist/cjs/apps/contracts/state-machines/contract.json +420 -0
- package/dist/cjs/apps/contracts/state-machines/escrow.json +426 -0
- package/dist/cjs/apps/contracts/types.js +48 -0
- package/dist/cjs/apps/corporate/index.js +112 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-board.json +1064 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-bylaws.json +751 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-committee.json +957 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-compliance.json +1293 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-entity.json +861 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-officers.json +843 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-proxy.json +783 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-resolution.json +1174 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-securities.json +1215 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-shareholders.json +1298 -0
- package/dist/cjs/apps/corporate/types.js +44 -0
- package/dist/cjs/apps/governance/index.js +203 -0
- package/dist/cjs/apps/governance/state-machines/dao-multisig.json +711 -0
- package/dist/cjs/apps/governance/state-machines/dao-single.json +258 -0
- package/dist/cjs/apps/governance/state-machines/dao-threshold.json +660 -0
- package/dist/cjs/apps/governance/state-machines/dao-token.json +680 -0
- package/dist/cjs/apps/governance/state-machines/governance-constitution.json +401 -0
- package/dist/cjs/apps/governance/state-machines/governance-executive.json +441 -0
- package/dist/cjs/apps/governance/state-machines/governance-judiciary.json +626 -0
- package/dist/cjs/apps/governance/state-machines/governance-legislature.json +726 -0
- package/dist/cjs/apps/governance/state-machines/governance-simple.json +679 -0
- package/dist/cjs/apps/governance/types.js +42 -0
- package/dist/cjs/apps/identity/constants.js +58 -0
- package/dist/cjs/apps/identity/index.js +78 -0
- package/dist/cjs/apps/identity/state-machines/agent-identity.json +320 -0
- package/dist/cjs/apps/identity/types.js +53 -0
- package/dist/cjs/apps/index.js +58 -0
- package/dist/cjs/apps/markets/index.js +55 -0
- package/dist/cjs/apps/markets/state-machines/market-universal.json +354 -0
- package/dist/cjs/apps/markets/types.js +219 -0
- package/dist/cjs/apps/oracles/index.js +62 -0
- package/dist/cjs/apps/oracles/state-machines/oracle.json +452 -0
- package/dist/cjs/apps/oracles/types.js +282 -0
- package/dist/cjs/errors.js +293 -0
- package/dist/cjs/generated/google/protobuf/struct.js +514 -0
- package/dist/cjs/generated/google/protobuf/timestamp.js +92 -0
- package/dist/cjs/generated/index.js +150 -0
- package/dist/cjs/generated/ottochain/apps/contracts/v1/contract.js +873 -0
- package/dist/cjs/generated/ottochain/apps/contracts/v1/contract_pb.js +100 -0
- package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +4515 -0
- package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate_pb.js +392 -0
- package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +3255 -0
- package/dist/cjs/generated/ottochain/apps/governance/v1/governance_pb.js +235 -0
- package/dist/cjs/generated/ottochain/apps/identity/v1/agent.js +619 -0
- package/dist/cjs/generated/ottochain/apps/identity/v1/agent_pb.js +116 -0
- package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +780 -0
- package/dist/cjs/generated/ottochain/apps/identity/v1/attestation_pb.js +79 -0
- package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +1261 -0
- package/dist/cjs/generated/ottochain/apps/markets/v1/market_pb.js +151 -0
- package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle.js +1223 -0
- package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle_pb.js +109 -0
- package/dist/cjs/generated/ottochain/v1/common.js +10 -0
- package/dist/cjs/generated/ottochain/v1/common_pb.js +37 -0
- package/dist/cjs/generated/ottochain/v1/fiber.js +1057 -0
- package/dist/cjs/generated/ottochain/v1/fiber_pb.js +86 -0
- package/dist/cjs/generated/ottochain/v1/messages.js +740 -0
- package/dist/cjs/generated/ottochain/v1/messages_pb.js +44 -0
- package/dist/cjs/generated/ottochain/v1/records.js +1253 -0
- package/dist/cjs/generated/ottochain/v1/records_pb.js +44 -0
- package/dist/cjs/index.js +79 -0
- package/dist/cjs/metakit/binary.js +58 -0
- package/dist/cjs/metakit/canonicalize.js +40 -0
- package/dist/cjs/metakit/codec.js +45 -0
- package/dist/cjs/metakit/currency-transaction.js +319 -0
- package/dist/cjs/metakit/currency-types.js +13 -0
- package/dist/cjs/metakit/hash.js +84 -0
- package/dist/cjs/metakit/index.js +74 -0
- package/dist/cjs/metakit/network/client.js +78 -0
- package/dist/cjs/metakit/network/currency-l1-client.js +101 -0
- package/dist/cjs/metakit/network/data-l1-client.js +76 -0
- package/dist/cjs/metakit/network/index.js +16 -0
- package/dist/cjs/metakit/network/types.js +20 -0
- package/dist/cjs/metakit/sign.js +120 -0
- package/dist/cjs/metakit/signed-object.js +100 -0
- package/dist/cjs/metakit/types.js +14 -0
- package/dist/cjs/metakit/verify.js +217 -0
- package/dist/cjs/metakit/wallet.js +127 -0
- package/dist/cjs/ottochain/index.js +47 -0
- package/dist/cjs/ottochain/metagraph-client.js +157 -0
- package/dist/cjs/ottochain/snapshot.js +110 -0
- package/dist/cjs/ottochain/types.js +11 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.js +25 -0
- package/dist/cjs/validation.js +312 -0
- package/dist/errors.d.ts +221 -0
- package/dist/errors.js +293 -0
- package/dist/esm/apps/contracts/index.js +42 -0
- package/dist/esm/apps/contracts/state-machines/contract.json +420 -0
- package/dist/esm/apps/contracts/state-machines/escrow.json +426 -0
- package/dist/esm/apps/contracts/types.js +44 -0
- package/dist/esm/apps/corporate/index.js +57 -0
- package/dist/esm/apps/corporate/state-machines/corporate-board.json +1064 -0
- package/dist/esm/apps/corporate/state-machines/corporate-bylaws.json +751 -0
- package/dist/esm/apps/corporate/state-machines/corporate-committee.json +957 -0
- package/dist/esm/apps/corporate/state-machines/corporate-compliance.json +1293 -0
- package/dist/esm/apps/corporate/state-machines/corporate-entity.json +861 -0
- package/dist/esm/apps/corporate/state-machines/corporate-officers.json +843 -0
- package/dist/esm/apps/corporate/state-machines/corporate-proxy.json +783 -0
- package/dist/esm/apps/corporate/state-machines/corporate-resolution.json +1174 -0
- package/dist/esm/apps/corporate/state-machines/corporate-securities.json +1215 -0
- package/dist/esm/apps/corporate/state-machines/corporate-shareholders.json +1298 -0
- package/dist/esm/apps/corporate/types.js +38 -0
- package/dist/esm/apps/governance/index.js +154 -0
- package/dist/esm/apps/governance/state-machines/dao-multisig.json +711 -0
- package/dist/esm/apps/governance/state-machines/dao-single.json +258 -0
- package/dist/esm/apps/governance/state-machines/dao-threshold.json +660 -0
- package/dist/esm/apps/governance/state-machines/dao-token.json +680 -0
- package/dist/esm/apps/governance/state-machines/governance-constitution.json +401 -0
- package/dist/esm/apps/governance/state-machines/governance-executive.json +441 -0
- package/dist/esm/apps/governance/state-machines/governance-judiciary.json +626 -0
- package/dist/esm/apps/governance/state-machines/governance-legislature.json +726 -0
- package/dist/esm/apps/governance/state-machines/governance-simple.json +679 -0
- package/dist/esm/apps/governance/types.js +35 -0
- package/dist/esm/apps/identity/constants.js +53 -0
- package/dist/esm/apps/identity/index.js +50 -0
- package/dist/esm/apps/identity/state-machines/agent-identity.json +320 -0
- package/dist/esm/apps/identity/types.js +50 -0
- package/dist/esm/apps/index.js +32 -0
- package/dist/esm/apps/markets/index.js +34 -0
- package/dist/esm/apps/markets/state-machines/market-universal.json +354 -0
- package/dist/esm/apps/markets/types.js +206 -0
- package/dist/esm/apps/oracles/index.js +42 -0
- package/dist/esm/apps/oracles/state-machines/oracle.json +452 -0
- package/dist/esm/apps/oracles/types.js +267 -0
- package/dist/esm/errors.js +283 -0
- package/dist/esm/generated/google/protobuf/struct.js +508 -0
- package/dist/esm/generated/google/protobuf/timestamp.js +89 -0
- package/dist/esm/generated/index.js +26 -0
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +867 -0
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract_pb.js +97 -0
- package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +4493 -0
- package/dist/esm/generated/ottochain/apps/corporate/v1/corporate_pb.js +389 -0
- package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +3240 -0
- package/dist/esm/generated/ottochain/apps/governance/v1/governance_pb.js +232 -0
- package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +610 -0
- package/dist/esm/generated/ottochain/apps/identity/v1/agent_pb.js +113 -0
- package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +774 -0
- package/dist/esm/generated/ottochain/apps/identity/v1/attestation_pb.js +76 -0
- package/dist/esm/generated/ottochain/apps/markets/v1/market.js +1252 -0
- package/dist/esm/generated/ottochain/apps/markets/v1/market_pb.js +148 -0
- package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +1217 -0
- package/dist/esm/generated/ottochain/apps/oracles/v1/oracle_pb.js +106 -0
- package/dist/esm/generated/ottochain/v1/common.js +7 -0
- package/dist/esm/generated/ottochain/v1/common_pb.js +34 -0
- package/dist/esm/generated/ottochain/v1/fiber.js +1051 -0
- package/dist/esm/generated/ottochain/v1/fiber_pb.js +83 -0
- package/dist/esm/generated/ottochain/v1/messages.js +737 -0
- package/dist/esm/generated/ottochain/v1/messages_pb.js +41 -0
- package/dist/esm/generated/ottochain/v1/records.js +1250 -0
- package/dist/esm/generated/ottochain/v1/records_pb.js +41 -0
- package/dist/esm/index.js +33 -0
- package/dist/esm/metakit/binary.js +53 -0
- package/dist/esm/metakit/canonicalize.js +33 -0
- package/dist/esm/metakit/codec.js +38 -0
- package/dist/esm/metakit/currency-transaction.js +306 -0
- package/dist/esm/metakit/currency-types.js +10 -0
- package/dist/esm/metakit/hash.js +77 -0
- package/dist/esm/metakit/index.js +30 -0
- package/dist/esm/metakit/network/client.js +74 -0
- package/dist/esm/metakit/network/currency-l1-client.js +97 -0
- package/dist/esm/metakit/network/data-l1-client.js +72 -0
- package/dist/esm/metakit/network/index.js +9 -0
- package/dist/esm/metakit/network/types.js +16 -0
- package/dist/esm/metakit/sign.js +114 -0
- package/dist/esm/metakit/signed-object.js +94 -0
- package/dist/esm/metakit/types.js +11 -0
- package/dist/esm/metakit/verify.js +210 -0
- package/dist/esm/metakit/wallet.js +117 -0
- package/dist/esm/ottochain/index.js +13 -0
- package/dist/esm/ottochain/metagraph-client.js +153 -0
- package/dist/esm/ottochain/snapshot.js +100 -0
- package/dist/esm/ottochain/types.js +10 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.js +20 -0
- package/dist/esm/validation.js +301 -0
- package/dist/generated/index.d.ts +15 -0
- package/dist/generated/index.js +34 -0
- package/dist/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +274 -0
- package/dist/generated/ottochain/apps/contracts/v1/contract_pb.js +100 -0
- package/dist/generated/ottochain/apps/identity/v1/agent_pb.d.ts +211 -0
- package/dist/generated/ottochain/apps/identity/v1/agent_pb.js +116 -0
- package/dist/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +238 -0
- package/dist/generated/ottochain/apps/identity/v1/attestation_pb.js +79 -0
- package/dist/generated/ottochain/apps/markets/v1/market_pb.d.ts +436 -0
- package/dist/generated/ottochain/apps/markets/v1/market_pb.js +151 -0
- package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +393 -0
- package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.js +109 -0
- package/dist/generated/ottochain/v1/common_pb.d.ts +86 -0
- package/dist/generated/ottochain/v1/common_pb.js +37 -0
- package/dist/generated/ottochain/v1/fiber_pb.d.ts +292 -0
- package/dist/generated/ottochain/v1/fiber_pb.js +86 -0
- package/dist/generated/ottochain/v1/messages_pb.d.ts +190 -0
- package/dist/generated/ottochain/v1/messages_pb.js +44 -0
- package/dist/generated/ottochain/v1/records_pb.d.ts +221 -0
- package/dist/generated/ottochain/v1/records_pb.js +44 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +77 -0
- package/dist/metakit/binary.d.ts +38 -0
- package/dist/metakit/binary.js +58 -0
- package/dist/metakit/canonicalize.d.ts +26 -0
- package/dist/metakit/canonicalize.js +40 -0
- package/dist/metakit/codec.d.ts +16 -0
- package/dist/metakit/codec.js +45 -0
- package/dist/metakit/currency-transaction.d.ts +157 -0
- package/dist/metakit/currency-transaction.js +319 -0
- package/dist/metakit/currency-types.d.ts +55 -0
- package/dist/metakit/currency-types.js +13 -0
- package/dist/metakit/hash.d.ts +50 -0
- package/dist/metakit/hash.js +84 -0
- package/dist/metakit/index.d.ts +23 -0
- package/dist/metakit/index.js +74 -0
- package/dist/metakit/network/client.d.ts +23 -0
- package/dist/metakit/network/client.js +78 -0
- package/dist/metakit/network/currency-l1-client.d.ts +71 -0
- package/dist/metakit/network/currency-l1-client.js +101 -0
- package/dist/metakit/network/data-l1-client.d.ts +57 -0
- package/dist/metakit/network/data-l1-client.js +76 -0
- package/dist/metakit/network/index.d.ts +10 -0
- package/dist/metakit/network/index.js +16 -0
- package/dist/metakit/network/types.d.ts +74 -0
- package/dist/metakit/network/types.js +20 -0
- package/dist/metakit/sign.d.ts +65 -0
- package/dist/metakit/sign.js +120 -0
- package/dist/metakit/signed-object.d.ts +66 -0
- package/dist/metakit/signed-object.js +100 -0
- package/dist/metakit/types.d.ts +67 -0
- package/dist/metakit/types.js +14 -0
- package/dist/metakit/verify.d.ts +55 -0
- package/dist/metakit/verify.js +217 -0
- package/dist/metakit/wallet.d.ts +70 -0
- package/dist/metakit/wallet.js +127 -0
- package/dist/ottochain/index.d.ts +13 -0
- package/dist/ottochain/index.js +45 -0
- package/dist/ottochain/metagraph-client.d.ts +111 -0
- package/dist/ottochain/metagraph-client.js +157 -0
- package/dist/ottochain/snapshot.d.ts +86 -0
- package/dist/ottochain/snapshot.js +110 -0
- package/dist/ottochain/types.d.ts +278 -0
- package/dist/ottochain/types.js +11 -0
- package/dist/types/apps/contracts/index.d.ts +30 -0
- package/dist/types/apps/contracts/types.d.ts +24 -0
- package/dist/types/apps/corporate/index.d.ts +27 -0
- package/dist/types/apps/corporate/types.d.ts +9861 -0
- package/dist/types/apps/governance/index.d.ts +77 -0
- package/dist/types/apps/governance/types.d.ts +344 -0
- package/dist/types/apps/identity/constants.d.ts +27 -0
- package/dist/types/apps/identity/index.d.ts +39 -0
- package/dist/types/apps/identity/types.d.ts +30 -0
- package/dist/types/apps/index.d.ts +31 -0
- package/dist/types/apps/markets/index.d.ts +26 -0
- package/dist/types/apps/markets/types.d.ts +155 -0
- package/dist/types/apps/oracles/index.d.ts +34 -0
- package/dist/types/apps/oracles/types.d.ts +193 -0
- package/dist/types/errors.d.ts +221 -0
- package/dist/types/generated/google/protobuf/struct.d.ts +134 -0
- package/dist/types/generated/google/protobuf/timestamp.d.ts +134 -0
- package/dist/types/generated/index.d.ts +18 -0
- package/dist/types/generated/ottochain/apps/contracts/v1/contract.d.ts +112 -0
- package/dist/types/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +274 -0
- package/dist/types/generated/ottochain/apps/corporate/v1/corporate.d.ts +376 -0
- package/dist/types/generated/ottochain/apps/corporate/v1/corporate_pb.d.ts +1172 -0
- package/dist/types/generated/ottochain/apps/governance/v1/governance.d.ts +296 -0
- package/dist/types/generated/ottochain/apps/governance/v1/governance_pb.d.ts +772 -0
- package/dist/types/generated/ottochain/apps/identity/v1/agent.d.ts +94 -0
- package/dist/types/generated/ottochain/apps/identity/v1/agent_pb.d.ts +211 -0
- package/dist/types/generated/ottochain/apps/identity/v1/attestation.d.ts +102 -0
- package/dist/types/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +238 -0
- package/dist/types/generated/ottochain/apps/markets/v1/market.d.ts +174 -0
- package/dist/types/generated/ottochain/apps/markets/v1/market_pb.d.ts +436 -0
- package/dist/types/generated/ottochain/apps/oracles/v1/oracle.d.ts +150 -0
- package/dist/types/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +393 -0
- package/dist/types/generated/ottochain/v1/common.d.ts +1 -0
- package/dist/types/generated/ottochain/v1/common_pb.d.ts +86 -0
- package/dist/types/generated/ottochain/v1/fiber.d.ts +130 -0
- package/dist/types/generated/ottochain/v1/fiber_pb.d.ts +292 -0
- package/dist/types/generated/ottochain/v1/messages.d.ts +89 -0
- package/dist/types/generated/ottochain/v1/messages_pb.d.ts +190 -0
- package/dist/types/generated/ottochain/v1/records.d.ts +128 -0
- package/dist/types/generated/ottochain/v1/records_pb.d.ts +221 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/metakit/binary.d.ts +38 -0
- package/dist/types/metakit/canonicalize.d.ts +26 -0
- package/dist/types/metakit/codec.d.ts +16 -0
- package/dist/types/metakit/currency-transaction.d.ts +157 -0
- package/dist/types/metakit/currency-types.d.ts +55 -0
- package/dist/types/metakit/hash.d.ts +50 -0
- package/dist/types/metakit/index.d.ts +23 -0
- package/dist/types/metakit/network/client.d.ts +23 -0
- package/dist/types/metakit/network/currency-l1-client.d.ts +71 -0
- package/dist/types/metakit/network/data-l1-client.d.ts +57 -0
- package/dist/types/metakit/network/index.d.ts +10 -0
- package/dist/types/metakit/network/types.d.ts +74 -0
- package/dist/types/metakit/sign.d.ts +65 -0
- package/dist/types/metakit/signed-object.d.ts +66 -0
- package/dist/types/metakit/types.d.ts +67 -0
- package/dist/types/metakit/verify.d.ts +55 -0
- package/dist/types/metakit/wallet.d.ts +70 -0
- package/dist/types/ottochain/index.d.ts +13 -0
- package/dist/types/ottochain/metagraph-client.d.ts +111 -0
- package/dist/types/ottochain/snapshot.d.ts +86 -0
- package/dist/types/ottochain/types.d.ts +210 -0
- package/dist/types/types.d.ts +51 -0
- package/dist/types/validation.d.ts +449 -0
- package/dist/validation.d.ts +449 -0
- package/dist/validation.js +312 -0
- package/package.json +136 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hashing Utilities
|
|
3
|
+
*
|
|
4
|
+
* SHA-256 and SHA-512 hashing for the Constellation signature protocol.
|
|
5
|
+
*/
|
|
6
|
+
import { Hash } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Compute SHA-256 hash of canonical JSON data
|
|
9
|
+
*
|
|
10
|
+
* @param data - Any JSON-serializable object
|
|
11
|
+
* @returns Hash object with hex string and raw bytes
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const hashResult = hash({ action: 'test' });
|
|
16
|
+
* console.log(hashResult.value); // 64-char hex string
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function hash<T>(data: T): Hash;
|
|
20
|
+
/**
|
|
21
|
+
* Compute SHA-256 hash of raw bytes
|
|
22
|
+
*
|
|
23
|
+
* @param bytes - Input bytes
|
|
24
|
+
* @returns Hash object with hex string and raw bytes
|
|
25
|
+
*/
|
|
26
|
+
export declare function hashBytes(bytes: Uint8Array): Hash;
|
|
27
|
+
/**
|
|
28
|
+
* Compute the full signing digest according to Constellation protocol
|
|
29
|
+
*
|
|
30
|
+
* Protocol:
|
|
31
|
+
* 1. Serialize data to binary (with optional DataUpdate prefix)
|
|
32
|
+
* 2. Compute SHA-256 hash
|
|
33
|
+
* 3. Convert hash to hex string
|
|
34
|
+
* 4. Treat hex string as UTF-8 bytes (NOT hex decode)
|
|
35
|
+
* 5. Compute SHA-512 of those bytes
|
|
36
|
+
* 6. Truncate to 32 bytes for secp256k1 signing
|
|
37
|
+
*
|
|
38
|
+
* @param data - Any JSON-serializable object
|
|
39
|
+
* @param isDataUpdate - Whether to apply DataUpdate encoding
|
|
40
|
+
* @returns 32-byte digest ready for ECDSA signing
|
|
41
|
+
*/
|
|
42
|
+
export declare function computeDigest<T>(data: T, isDataUpdate?: boolean): Uint8Array;
|
|
43
|
+
/**
|
|
44
|
+
* Compute SHA-256 hash of data with optional DataUpdate encoding
|
|
45
|
+
*
|
|
46
|
+
* @param data - Any JSON-serializable object
|
|
47
|
+
* @param isDataUpdate - Whether to apply DataUpdate encoding
|
|
48
|
+
* @returns Hash object
|
|
49
|
+
*/
|
|
50
|
+
export declare function hashData<T>(data: T, isDataUpdate?: boolean): Hash;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metakit SDK
|
|
3
|
+
*
|
|
4
|
+
* Reusable signing, encoding, and network operations for Constellation metagraphs.
|
|
5
|
+
* This module is framework-level functionality, independent of any specific metagraph domain.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export type { SignatureProof, Signed, KeyPair, Hash, VerificationResult, SigningOptions, } from './types.js';
|
|
10
|
+
export { ALGORITHM, CONSTELLATION_PREFIX } from './types.js';
|
|
11
|
+
export { canonicalize } from './canonicalize.js';
|
|
12
|
+
export { toBytes, encodeDataUpdate } from './binary.js';
|
|
13
|
+
export { hash, hashBytes, hashData, computeDigest } from './hash.js';
|
|
14
|
+
export { decodeDataUpdate } from './codec.js';
|
|
15
|
+
export { sign, signDataUpdate, signHash } from './sign.js';
|
|
16
|
+
export { verify, verifyHash, verifySignature } from './verify.js';
|
|
17
|
+
export { createSignedObject, addSignature, batchSign } from './signed-object.js';
|
|
18
|
+
export { generateKeyPair, keyPairFromPrivateKey, getPublicKeyHex, getPublicKeyId, getAddress, isValidPrivateKey, isValidPublicKey, } from './wallet.js';
|
|
19
|
+
export type { TransactionReference, CurrencyTransactionValue, CurrencyTransaction, TransferParams, } from './currency-types.js';
|
|
20
|
+
export { TOKEN_DECIMALS } from './currency-types.js';
|
|
21
|
+
export { createCurrencyTransaction, createCurrencyTransactionBatch, signCurrencyTransaction, verifyCurrencyTransaction, encodeCurrencyTransaction, hashCurrencyTransaction, getTransactionReference, isValidDagAddress, tokenToUnits, unitsToToken, } from './currency-transaction.js';
|
|
22
|
+
export { CurrencyL1Client, DataL1Client, HttpClient, NetworkError } from './network/index.js';
|
|
23
|
+
export type { NetworkConfig, RequestOptions, TransactionStatus, PendingTransaction, PostTransactionResponse, EstimateFeeResponse, PostDataResponse, } from './network/index.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base HTTP client for network operations
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { RequestOptions } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Simple HTTP client using native fetch
|
|
9
|
+
*/
|
|
10
|
+
export declare class HttpClient {
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private defaultTimeout;
|
|
13
|
+
constructor(baseUrl: string, timeout?: number);
|
|
14
|
+
/**
|
|
15
|
+
* Make a GET request
|
|
16
|
+
*/
|
|
17
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Make a POST request
|
|
20
|
+
*/
|
|
21
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
22
|
+
private request;
|
|
23
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency L1 client for submitting and querying transactions
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { NetworkConfig, PendingTransaction, PostTransactionResponse, RequestOptions } from './types.js';
|
|
7
|
+
import type { TransactionReference, CurrencyTransaction } from '../currency-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Client for interacting with Currency L1 nodes
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const client = new CurrencyL1Client({ l1Url: 'http://localhost:9010' });
|
|
14
|
+
*
|
|
15
|
+
* // Get last reference for an address
|
|
16
|
+
* const lastRef = await client.getLastReference('DAG...');
|
|
17
|
+
*
|
|
18
|
+
* // Submit a transaction
|
|
19
|
+
* const result = await client.postTransaction(signedTx);
|
|
20
|
+
*
|
|
21
|
+
* // Check transaction status
|
|
22
|
+
* const pending = await client.getPendingTransaction(result.hash);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class CurrencyL1Client {
|
|
26
|
+
private client;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new CurrencyL1Client
|
|
29
|
+
*
|
|
30
|
+
* @param config - Network configuration with l1Url
|
|
31
|
+
* @throws Error if l1Url is not provided
|
|
32
|
+
*/
|
|
33
|
+
constructor(config: NetworkConfig);
|
|
34
|
+
/**
|
|
35
|
+
* Get the last accepted transaction reference for an address
|
|
36
|
+
*
|
|
37
|
+
* This is needed to create a new transaction that chains from
|
|
38
|
+
* the address's most recent transaction.
|
|
39
|
+
*
|
|
40
|
+
* @param address - DAG address to query
|
|
41
|
+
* @param options - Request options
|
|
42
|
+
* @returns Transaction reference with hash and ordinal
|
|
43
|
+
*/
|
|
44
|
+
getLastReference(address: string, options?: RequestOptions): Promise<TransactionReference>;
|
|
45
|
+
/**
|
|
46
|
+
* Submit a signed currency transaction to the L1 network
|
|
47
|
+
*
|
|
48
|
+
* @param transaction - Signed currency transaction
|
|
49
|
+
* @param options - Request options
|
|
50
|
+
* @returns Response containing the transaction hash
|
|
51
|
+
*/
|
|
52
|
+
postTransaction(transaction: CurrencyTransaction, options?: RequestOptions): Promise<PostTransactionResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Get a pending transaction by hash
|
|
55
|
+
*
|
|
56
|
+
* Use this to poll for transaction status after submission.
|
|
57
|
+
* Returns null if the transaction is not found (already confirmed or invalid).
|
|
58
|
+
*
|
|
59
|
+
* @param hash - Transaction hash
|
|
60
|
+
* @param options - Request options
|
|
61
|
+
* @returns Pending transaction details or null if not found
|
|
62
|
+
*/
|
|
63
|
+
getPendingTransaction(hash: string, options?: RequestOptions): Promise<PendingTransaction | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Check the health/availability of the L1 node
|
|
66
|
+
*
|
|
67
|
+
* @param options - Request options
|
|
68
|
+
* @returns True if the node is healthy
|
|
69
|
+
*/
|
|
70
|
+
checkHealth(options?: RequestOptions): Promise<boolean>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data L1 client for submitting data transactions to metagraphs
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { NetworkConfig, EstimateFeeResponse, PostDataResponse, RequestOptions } from './types.js';
|
|
7
|
+
import type { Signed } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Client for interacting with Data L1 nodes (metagraphs)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const client = new DataL1Client({ dataL1Url: 'http://localhost:8080' });
|
|
14
|
+
*
|
|
15
|
+
* // Estimate fee for data submission
|
|
16
|
+
* const feeInfo = await client.estimateFee(signedData);
|
|
17
|
+
*
|
|
18
|
+
* // Submit data
|
|
19
|
+
* const result = await client.postData(signedData);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class DataL1Client {
|
|
23
|
+
private client;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new DataL1Client
|
|
26
|
+
*
|
|
27
|
+
* @param config - Network configuration with dataL1Url
|
|
28
|
+
* @throws Error if dataL1Url is not provided
|
|
29
|
+
*/
|
|
30
|
+
constructor(config: NetworkConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Estimate the fee for submitting data
|
|
33
|
+
*
|
|
34
|
+
* Some metagraphs charge fees for data submissions.
|
|
35
|
+
* Call this before postData to know the required fee.
|
|
36
|
+
*
|
|
37
|
+
* @param data - Signed data object to estimate fee for
|
|
38
|
+
* @param options - Request options
|
|
39
|
+
* @returns Fee estimate with amount and destination address
|
|
40
|
+
*/
|
|
41
|
+
estimateFee<T>(data: Signed<T>, options?: RequestOptions): Promise<EstimateFeeResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Submit signed data to the Data L1 node
|
|
44
|
+
*
|
|
45
|
+
* @param data - Signed data object to submit
|
|
46
|
+
* @param options - Request options
|
|
47
|
+
* @returns Response containing the data hash
|
|
48
|
+
*/
|
|
49
|
+
postData<T>(data: Signed<T>, options?: RequestOptions): Promise<PostDataResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Check the health/availability of the Data L1 node
|
|
52
|
+
*
|
|
53
|
+
* @param options - Request options
|
|
54
|
+
* @returns True if the node is healthy
|
|
55
|
+
*/
|
|
56
|
+
checkHealth(options?: RequestOptions): Promise<boolean>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network operations for L1 node interactions
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { CurrencyL1Client } from './currency-l1-client.js';
|
|
7
|
+
export { DataL1Client } from './data-l1-client.js';
|
|
8
|
+
export { HttpClient } from './client.js';
|
|
9
|
+
export { NetworkError } from './types.js';
|
|
10
|
+
export type { NetworkConfig, RequestOptions, TransactionStatus, PendingTransaction, PostTransactionResponse, EstimateFeeResponse, PostDataResponse, } from './types.js';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network types for L1 client operations
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { CurrencyTransaction } from '../currency-types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Network configuration for connecting to L1 nodes
|
|
9
|
+
*/
|
|
10
|
+
export interface NetworkConfig {
|
|
11
|
+
/** Currency L1 endpoint URL (e.g., 'http://localhost:9010') */
|
|
12
|
+
l1Url?: string;
|
|
13
|
+
/** Data L1 endpoint URL (e.g., 'http://localhost:8080') */
|
|
14
|
+
dataL1Url?: string;
|
|
15
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* HTTP request options
|
|
20
|
+
*/
|
|
21
|
+
export interface RequestOptions {
|
|
22
|
+
/** Request timeout in milliseconds */
|
|
23
|
+
timeout?: number;
|
|
24
|
+
/** Additional headers */
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Transaction status in the network
|
|
29
|
+
*/
|
|
30
|
+
export type TransactionStatus = 'Waiting' | 'InProgress' | 'Accepted';
|
|
31
|
+
/**
|
|
32
|
+
* Pending transaction response from L1
|
|
33
|
+
*/
|
|
34
|
+
export interface PendingTransaction {
|
|
35
|
+
/** Transaction hash */
|
|
36
|
+
hash: string;
|
|
37
|
+
/** Current status */
|
|
38
|
+
status: TransactionStatus;
|
|
39
|
+
/** The transaction value */
|
|
40
|
+
transaction: CurrencyTransaction;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Response from posting a transaction
|
|
44
|
+
*/
|
|
45
|
+
export interface PostTransactionResponse {
|
|
46
|
+
/** Transaction hash */
|
|
47
|
+
hash: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Response from estimating data transaction fee
|
|
51
|
+
*/
|
|
52
|
+
export interface EstimateFeeResponse {
|
|
53
|
+
/** Estimated fee in smallest units */
|
|
54
|
+
fee: number;
|
|
55
|
+
/** Fee destination address */
|
|
56
|
+
address: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Response from posting data
|
|
60
|
+
*/
|
|
61
|
+
export interface PostDataResponse {
|
|
62
|
+
/** Data hash */
|
|
63
|
+
hash: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Network error with status code and response details
|
|
67
|
+
*/
|
|
68
|
+
export declare class NetworkError extends Error {
|
|
69
|
+
/** HTTP status code if applicable */
|
|
70
|
+
statusCode?: number;
|
|
71
|
+
/** Raw response body */
|
|
72
|
+
responseBody?: string;
|
|
73
|
+
constructor(message: string, statusCode?: number, responseBody?: string);
|
|
74
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing Functions
|
|
3
|
+
*
|
|
4
|
+
* ECDSA signing using secp256k1 curve via dag4js.
|
|
5
|
+
* Implements the Constellation signature protocol.
|
|
6
|
+
*/
|
|
7
|
+
import { SignatureProof } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Sign data using the regular Constellation protocol (non-DataUpdate)
|
|
10
|
+
*
|
|
11
|
+
* Protocol:
|
|
12
|
+
* 1. Canonicalize JSON (RFC 8785)
|
|
13
|
+
* 2. SHA-256 hash the canonical JSON string
|
|
14
|
+
* 3. Sign using dag4.keyStore.sign
|
|
15
|
+
*
|
|
16
|
+
* @param data - Any JSON-serializable object
|
|
17
|
+
* @param privateKey - Private key in hex format
|
|
18
|
+
* @returns SignatureProof with public key ID and signature
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const proof = await sign({ action: 'test' }, privateKeyHex);
|
|
23
|
+
* console.log(proof.id); // public key (128 chars)
|
|
24
|
+
* console.log(proof.signature); // DER signature
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function sign<T>(data: T, privateKey: string): Promise<SignatureProof>;
|
|
28
|
+
/**
|
|
29
|
+
* Sign data as a DataUpdate (with Constellation prefix)
|
|
30
|
+
*
|
|
31
|
+
* Protocol:
|
|
32
|
+
* 1. Canonicalize JSON (RFC 8785)
|
|
33
|
+
* 2. Base64 encode the canonical JSON
|
|
34
|
+
* 3. Sign using dag4.keyStore.dataSign (adds Constellation prefix internally)
|
|
35
|
+
*
|
|
36
|
+
* @param data - Any JSON-serializable object
|
|
37
|
+
* @param privateKey - Private key in hex format
|
|
38
|
+
* @returns SignatureProof
|
|
39
|
+
*/
|
|
40
|
+
export declare function signDataUpdate<T>(data: T, privateKey: string): Promise<SignatureProof>;
|
|
41
|
+
/**
|
|
42
|
+
* Sign a pre-computed SHA-256 hash
|
|
43
|
+
*
|
|
44
|
+
* This is the low-level signing function. Use `sign()` or `signDataUpdate()`
|
|
45
|
+
* for most use cases.
|
|
46
|
+
*
|
|
47
|
+
* Protocol (performed by dag4.keyStore.sign):
|
|
48
|
+
* 1. Treat hashHex as UTF-8 bytes (64 ASCII characters = 64 bytes)
|
|
49
|
+
* 2. SHA-512 hash those bytes (produces 64 bytes)
|
|
50
|
+
* 3. Truncate to first 32 bytes (for secp256k1 curve order)
|
|
51
|
+
* 4. Sign with ECDSA secp256k1
|
|
52
|
+
* 5. Return DER-encoded signature
|
|
53
|
+
*
|
|
54
|
+
* @param hashHex - SHA-256 hash as 64-character hex string
|
|
55
|
+
* @param privateKey - Private key in hex format (64 characters)
|
|
56
|
+
* @returns DER-encoded signature in hex format
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Compute your own hash
|
|
61
|
+
* const hashHex = sha256(myData);
|
|
62
|
+
* const signature = await signHash(hashHex, privateKey);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function signHash(hashHex: string, privateKey: string): Promise<string>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-Level Signed Object API
|
|
3
|
+
*
|
|
4
|
+
* Convenience functions for creating and managing signed objects.
|
|
5
|
+
*/
|
|
6
|
+
import { Signed, SigningOptions } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Create a signed object with a single signature
|
|
9
|
+
*
|
|
10
|
+
* @param value - Any JSON-serializable object
|
|
11
|
+
* @param privateKey - Private key in hex format
|
|
12
|
+
* @param options - Signing options
|
|
13
|
+
* @returns Signed object ready for submission
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Sign a regular data object
|
|
18
|
+
* const signed = await createSignedObject(myData, privateKey);
|
|
19
|
+
*
|
|
20
|
+
* // Sign as DataUpdate for L1 submission
|
|
21
|
+
* const signedUpdate = await createSignedObject(myData, privateKey, { isDataUpdate: true });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSignedObject<T>(value: T, privateKey: string, options?: SigningOptions): Promise<Signed<T>>;
|
|
25
|
+
/**
|
|
26
|
+
* Add an additional signature to an existing signed object
|
|
27
|
+
*
|
|
28
|
+
* This allows building multi-signature objects where multiple parties
|
|
29
|
+
* need to sign the same data.
|
|
30
|
+
*
|
|
31
|
+
* @param signed - Existing signed object
|
|
32
|
+
* @param privateKey - Private key in hex format
|
|
33
|
+
* @param options - Signing options (must match original signing)
|
|
34
|
+
* @returns New signed object with additional proof
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // First party signs
|
|
39
|
+
* let signed = await createSignedObject(data, party1Key);
|
|
40
|
+
*
|
|
41
|
+
* // Second party adds signature
|
|
42
|
+
* signed = await addSignature(signed, party2Key);
|
|
43
|
+
*
|
|
44
|
+
* // Now has 2 proofs
|
|
45
|
+
* console.log(signed.proofs.length); // 2
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function addSignature<T>(signed: Signed<T>, privateKey: string, options?: SigningOptions): Promise<Signed<T>>;
|
|
49
|
+
/**
|
|
50
|
+
* Create a signed object with multiple signatures at once
|
|
51
|
+
*
|
|
52
|
+
* Useful when you have access to multiple private keys and want
|
|
53
|
+
* to create a multi-sig object in one operation.
|
|
54
|
+
*
|
|
55
|
+
* @param value - Any JSON-serializable object
|
|
56
|
+
* @param privateKeys - Array of private keys in hex format
|
|
57
|
+
* @param options - Signing options
|
|
58
|
+
* @returns Signed object with multiple proofs
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const signed = await batchSign(data, [key1, key2, key3]);
|
|
63
|
+
* console.log(signed.proofs.length); // 3
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function batchSign<T>(value: T, privateKeys: string[], options?: SigningOptions): Promise<Signed<T>>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the Ottochain SDK
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A signature proof containing the signer's public key ID and signature
|
|
6
|
+
*/
|
|
7
|
+
export interface SignatureProof {
|
|
8
|
+
/** Public key hex (uncompressed, without 04 prefix) - 128 characters */
|
|
9
|
+
id: string;
|
|
10
|
+
/** DER-encoded ECDSA signature in hex format */
|
|
11
|
+
signature: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A signed object wrapping a value with one or more signature proofs
|
|
15
|
+
*/
|
|
16
|
+
export interface Signed<T> {
|
|
17
|
+
/** The signed value */
|
|
18
|
+
value: T;
|
|
19
|
+
/** Array of signature proofs */
|
|
20
|
+
proofs: SignatureProof[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A key pair for signing operations
|
|
24
|
+
*/
|
|
25
|
+
export interface KeyPair {
|
|
26
|
+
/** Private key in hex format */
|
|
27
|
+
privateKey: string;
|
|
28
|
+
/** Public key in hex format (uncompressed, with 04 prefix) */
|
|
29
|
+
publicKey: string;
|
|
30
|
+
/** DAG address derived from the public key */
|
|
31
|
+
address: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A hash result containing both hex string and raw bytes
|
|
35
|
+
*/
|
|
36
|
+
export interface Hash {
|
|
37
|
+
/** SHA-256 hash as 64-character hex string */
|
|
38
|
+
value: string;
|
|
39
|
+
/** Raw 32-byte hash as Uint8Array */
|
|
40
|
+
bytes: Uint8Array;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Result of signature verification
|
|
44
|
+
*/
|
|
45
|
+
export interface VerificationResult {
|
|
46
|
+
/** Whether all signatures are valid */
|
|
47
|
+
isValid: boolean;
|
|
48
|
+
/** Proofs that passed verification */
|
|
49
|
+
validProofs: SignatureProof[];
|
|
50
|
+
/** Proofs that failed verification */
|
|
51
|
+
invalidProofs: SignatureProof[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for signing operations
|
|
55
|
+
*/
|
|
56
|
+
export interface SigningOptions {
|
|
57
|
+
/** Whether to sign as a DataUpdate (with Constellation prefix) */
|
|
58
|
+
isDataUpdate?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Supported signature algorithm
|
|
62
|
+
*/
|
|
63
|
+
export declare const ALGORITHM: "SECP256K1_RFC8785_V1";
|
|
64
|
+
/**
|
|
65
|
+
* Constellation prefix for DataUpdate signing
|
|
66
|
+
*/
|
|
67
|
+
export declare const CONSTELLATION_PREFIX = "\u0019Constellation Signed Data:\n";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature Verification
|
|
3
|
+
*
|
|
4
|
+
* Verify ECDSA signatures using secp256k1 curve via dag4js.
|
|
5
|
+
*/
|
|
6
|
+
import { Signed, SignatureProof, VerificationResult } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Verify a signed object
|
|
9
|
+
*
|
|
10
|
+
* @param signed - Signed object with value and proofs
|
|
11
|
+
* @param isDataUpdate - Whether the value was signed as a DataUpdate
|
|
12
|
+
* @returns VerificationResult with valid/invalid proof lists
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const result = await verify(signedObject);
|
|
17
|
+
* if (result.isValid) {
|
|
18
|
+
* console.log('All signatures valid');
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function verify<T>(signed: Signed<T>, isDataUpdate?: boolean): Promise<VerificationResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Verify a signature against a SHA-256 hash
|
|
25
|
+
*
|
|
26
|
+
* Protocol:
|
|
27
|
+
* 1. Treat hash hex as UTF-8 bytes (NOT hex decode)
|
|
28
|
+
* 2. SHA-512 hash
|
|
29
|
+
* 3. Truncate to 32 bytes (handled internally by dag4)
|
|
30
|
+
* 4. Verify ECDSA signature
|
|
31
|
+
*
|
|
32
|
+
* @param hashHex - SHA-256 hash as 64-character hex string
|
|
33
|
+
* @param signature - DER-encoded signature in hex format
|
|
34
|
+
* @param publicKeyId - Public key in hex (with or without 04 prefix)
|
|
35
|
+
* @returns true if signature is valid
|
|
36
|
+
*/
|
|
37
|
+
export declare function verifyHash(hashHex: string, signature: string, publicKeyId: string): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Verify a single signature proof against data
|
|
40
|
+
*
|
|
41
|
+
* @param data - The original data that was signed
|
|
42
|
+
* @param proof - The signature proof to verify
|
|
43
|
+
* @param isDataUpdate - Whether data was signed as DataUpdate
|
|
44
|
+
* @returns true if signature is valid
|
|
45
|
+
*/
|
|
46
|
+
export declare function verifySignature<T>(data: T, proof: SignatureProof, isDataUpdate?: boolean): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Normalize a DER-encoded signature to use low-S value.
|
|
49
|
+
*
|
|
50
|
+
* BIP 62/146 requires S values to be in the lower half of the curve order.
|
|
51
|
+
* Some signing implementations produce high-S signatures which are mathematically
|
|
52
|
+
* valid but rejected by strict verifiers. This normalizes high-S to low-S by
|
|
53
|
+
* computing S' = N - S where N is the curve order.
|
|
54
|
+
*/
|
|
55
|
+
export declare function normalizeSignatureToLowS(signatureHex: string): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet and Key Management Utilities
|
|
3
|
+
*
|
|
4
|
+
* Functions for generating and managing cryptographic keys.
|
|
5
|
+
*/
|
|
6
|
+
import { KeyPair } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Generate a new random key pair
|
|
9
|
+
*
|
|
10
|
+
* @returns KeyPair with private key, public key, and DAG address
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const keyPair = generateKeyPair();
|
|
15
|
+
* console.log(keyPair.address); // DAG address
|
|
16
|
+
* console.log(keyPair.privateKey); // 64 char hex
|
|
17
|
+
* console.log(keyPair.publicKey); // 130 char hex (with 04 prefix)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateKeyPair(): KeyPair;
|
|
21
|
+
/**
|
|
22
|
+
* Derive a key pair from an existing private key
|
|
23
|
+
*
|
|
24
|
+
* @param privateKey - Private key in hex format (64 characters)
|
|
25
|
+
* @returns KeyPair with private key, public key, and DAG address
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const keyPair = keyPairFromPrivateKey(existingPrivateKey);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function keyPairFromPrivateKey(privateKey: string): KeyPair;
|
|
33
|
+
/**
|
|
34
|
+
* Get the public key hex from a private key
|
|
35
|
+
*
|
|
36
|
+
* @param privateKey - Private key in hex format
|
|
37
|
+
* @param compressed - If true, returns compressed public key (33 bytes)
|
|
38
|
+
* @returns Public key in hex format
|
|
39
|
+
*/
|
|
40
|
+
export declare function getPublicKeyHex(privateKey: string, compressed?: boolean): string;
|
|
41
|
+
/**
|
|
42
|
+
* Get the public key ID (without 04 prefix) from a private key
|
|
43
|
+
*
|
|
44
|
+
* This format is used in SignatureProof.id
|
|
45
|
+
*
|
|
46
|
+
* @param privateKey - Private key in hex format
|
|
47
|
+
* @returns Public key ID (128 characters, no 04 prefix)
|
|
48
|
+
*/
|
|
49
|
+
export declare function getPublicKeyId(privateKey: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Get DAG address from a public key
|
|
52
|
+
*
|
|
53
|
+
* @param publicKey - Public key in hex format (with or without 04 prefix)
|
|
54
|
+
* @returns DAG address string
|
|
55
|
+
*/
|
|
56
|
+
export declare function getAddress(publicKey: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Validate that a private key is correctly formatted
|
|
59
|
+
*
|
|
60
|
+
* @param privateKey - Private key to validate
|
|
61
|
+
* @returns true if valid hex string of correct length
|
|
62
|
+
*/
|
|
63
|
+
export declare function isValidPrivateKey(privateKey: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Validate that a public key is correctly formatted
|
|
66
|
+
*
|
|
67
|
+
* @param publicKey - Public key to validate
|
|
68
|
+
* @returns true if valid hex string of correct length
|
|
69
|
+
*/
|
|
70
|
+
export declare function isValidPublicKey(publicKey: string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ottochain SDK
|
|
3
|
+
*
|
|
4
|
+
* Domain-specific types and clients for the ottochain metagraph.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export * as proto from '../generated/index.js';
|
|
9
|
+
export type { Address, FiberId, StateId, HashValue, FiberOrdinal, SnapshotOrdinal, JsonLogicValue, JsonLogicExpression, FiberStatus, AccessControlPolicy, StateMachineDefinition, EmittedEvent, EventReceipt, OracleInvocation, FiberLogEntry, StateMachineFiberRecord, ScriptFiberRecord, FiberRecord, FiberCommit, OnChain, CalculatedState, CreateStateMachine, TransitionStateMachine, ArchiveStateMachine, CreateScript, InvokeScript, OttochainMessage, } from './types.js';
|
|
10
|
+
export type { CurrencySnapshotResponse } from './snapshot.js';
|
|
11
|
+
export { decodeOnChainState, getSnapshotOnChainState, getLatestOnChainState, getLogsForFiber, getEventReceipts, getScriptInvocations, extractOnChainState, } from './snapshot.js';
|
|
12
|
+
export type { Checkpoint, MetagraphClientConfig } from './metagraph-client.js';
|
|
13
|
+
export { MetagraphClient } from './metagraph-client.js';
|