mirror of
https://github.com/luxfi/esign.git
synced 2026-10-30 16:58:18 +00:00
This commit lands the first end-to-end signable surface:
* pkg/sign — Signer/Verifier interfaces, Ed25519 implementation
(stdlib crypto/ed25519), method-dispatch helper. 8 unit tests:
round-trip, deterministic-from-seed, bad-seed-length, tampered
payload + sig, bad pubkey, bad sig length, zero-value verifier.
* pkg/envelope — added Signature.SignerHashHex() and SeqString
helper used by the verifier-side error reporting.
* pkg/api — Handler with pluggable Store, in-memory MemStore for
tests + small deployments. CreateRequest / SignRequest /
TransitionRequest / VerifyResponse types form the wire surface.
Handler.Sign runs cryptographic verify BEFORE calling
envelope.AddSignature so a malformed sig never lands in the
envelope. 3 e2e tests cover happy path, sig tampering detection,
and crypto-fails-before-store ordering.
* pkg/api — opcode table (Create/Get/Sign/Transition/Verify/Audit
+ Ping). ZAPServer serves [4B BE length][2B LE opcode][JSON body]
framing with per-conn pipelining + idle timeout. Tests: ping,
end-to-end create→sent→sign→verify, unknown opcode error,
bad-JSON error.
* cmd/esignd — standalone daemon. `--zap :9650` by default.
SIGINT/SIGTERM shutdown drains inflight conns before exit.
Test summary: 3 packages, 22 tests, all green.
41 lines
1.5 KiB
Go
41 lines
1.5 KiB
Go
// Copyright 2026 Lux Industries Inc. and the luxfi/esign authors.
|
|
// Licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
|
|
// Package api exposes the ZAP RPC surface of luxfi/esign.
|
|
//
|
|
// The wire is native ZAP: 4-byte big-endian length prefix, 2-byte
|
|
// little-endian opcode, then opcode-specific JSON body. The same handler
|
|
// table can also be wired to HTTP through a thin shim in cmd/esignd.
|
|
package api
|
|
|
|
// ZAP opcodes for the eSign RPC surface. Values are little-endian on the
|
|
// wire. Stay in lockstep with any client implementation — once an opcode
|
|
// is wired into production it MUST NOT be reassigned.
|
|
const (
|
|
// OpEnvelopeCreate accepts a CreateRequest and returns the envelope ID.
|
|
OpEnvelopeCreate uint16 = 0x0001
|
|
|
|
// OpEnvelopeGet accepts an ID, returns the envelope state + audit chain.
|
|
OpEnvelopeGet uint16 = 0x0002
|
|
|
|
// OpEnvelopeSign accepts (envelopeID, SignerHash, Method, Sig, PubKey),
|
|
// validates + appends to the envelope.
|
|
OpEnvelopeSign uint16 = 0x0003
|
|
|
|
// OpEnvelopeTransition accepts (envelopeID, target state, actor),
|
|
// runs the state machine.
|
|
OpEnvelopeTransition uint16 = 0x0004
|
|
|
|
// OpEnvelopeVerify accepts (envelopeID), recomputes every signature
|
|
// against the stored dochash, recomputes the audit chain, returns
|
|
// either "verified" or the first index of the broken record.
|
|
OpEnvelopeVerify uint16 = 0x0005
|
|
|
|
// OpAuditChain accepts an envelope ID, returns the full audit chain
|
|
// for external archival.
|
|
OpAuditChain uint16 = 0x0006
|
|
|
|
// OpPing — health probe. Empty body in, empty body out.
|
|
OpPing uint16 = 0x00FF
|
|
)
|