@orangecheck/stamp-core
v1.0.0
Published
OC Stamp canonical message, envelope format, stamp and verify. See https://github.com/orangecheck/oc-stamp-protocol.
Maintainers
Readme
@orangecheck/stamp-core
Canonical message, envelope format, stamp(), and verify() for OC Stamp.
Install
npm i @orangecheck/stamp-coreUsage
import { stamp, verify } from '@orangecheck/stamp-core';
// Produce a signed stamp envelope.
const env = await stamp({
content: new TextEncoder().encode('hello world'),
mime: 'text/plain',
signer: {
address: 'bc1qalice…',
signMessage: async (msg) => walletSignBIP322(msg),
},
});
// Share env as JSON, or via a URL fragment:
// https://stamp.ochk.io/v#<base64url(JSON)>
// OTS anchoring is a separate step — see @orangecheck/stamp-ots.
// A verifier, later:
const result = await verify({
envelope: env,
content: new TextEncoder().encode('hello world'),
verifyBip322: async (msg, sig, addr) => { /* your verifier */ },
});
if (!result.ok) throw new Error(`${result.code}: ${result.message}`);Exports
stamp(input)→StampEnvelope— build a signed envelope. Leavesots: null; anchoring is a later step.verify(input)→VerifyResult— full verification algorithm per SPEC §8. Returns a discriminated{ok: true, ...} | {ok: false, code, message}.canonicalMessage(input)→string— the exact bytes the signer signs via BIP-322.computeEnvelopeId(input)→string— lowercase hex ofsha256(canonical_message).canonicalize(value)/canonicalizeEnvelope(env)— RFC 8785 JSON canonicalization.StampError— typed error with protocol-definedcode.- Full type definitions:
StampEnvelope,StampInput,VerifyInput,StampStake, etc.
Composition
- OTS anchoring: use
@orangecheck/stamp-otsto submit an envelope'sidto OpenTimestamps calendars, parse returned proofs, and upgrade pending → confirmed. - Stake context: populate
input.stakewith an OrangeCheck attestation reference. Verifiers who care should re-resolve via@orangecheck/sdk. - BIP-322 signing: plug in any wallet adapter — the SDK doesn't ship one. See
@orangecheck/wallet-adapterfor the cross-wallet reference adapter. - BIP-322 verification: plug in a verifier via
verify({ verifyBip322 }). Node environments can usebip322-js; browser environments can use the same via a Buffer polyfill.
See SPEC.md for the normative spec.
