This specification defines the Provncloud SDK protocol for privacy-preserving digital signatures and data anchoring.
- Privacy: Raw data never leaves signing device (hash-only mode)
- Interoperability: Claims signed in any language can be verified in any other
- Determinism: Identical inputs produce identical signatures
- Efficiency: Optimized for L3 batching with 2KB metadata limit
interface Claim {
data: string; // Required. Data hash or raw data
timestamp: number; // Required. Unix timestamp (seconds)
metadata?: string; // Optional. Additional context
}Field Ordering: Alphabetically: data, metadata, timestamp
Constraints:
data: Non-empty string, typically SHA-256 hashtimestamp: Positive integermetadata: If present, serialized claim MUST NOT exceed 2KB
interface SignedClaim {
claim: Claim;
public_key: string; // Hex-encoded Ed25519 public key (64 hex chars)
signature: string; // Hex-encoded Ed25519 signature (128 hex chars)
}All structures MUST be serialized using JCS for deterministic output.
Example:
// Claim
{ "data": "abc123", "timestamp": 1704067200 }
// Canonical JSON
{"data":"abc123","timestamp":1704067200}Requirements:
- No whitespace
- Sorted object keys
- UTF-8 encoding
Function: compute_hash(data: &[u8]) -> String
Input: Arbitrary bytes
Output: Lowercase hex string (64 chars)
Key Format:
- Private key: 32 bytes
- Public key: 32 bytes
- Signature: 64 bytes
Encoding: Hex-encoded (lowercase)
Returns Ed25519 keypair (private: 32 bytes, public: 32 bytes)
Returns SHA-256 hash as hex string
- Validate claim
- Check 2KB limit
- Serialize to canonical JSON
- Sign with Ed25519
- Return SignedClaim
- Decode hex public key
- Decode hex signature
- Serialize claim
- Verify Ed25519 signature
- Return boolean
Payload Limit: 2KB (2048 bytes) for the entire serialized JSON structure.
Error message: "Error: Payload too large. Tip: For large datasets, hash the file locally and anchor the hash instead of the raw data."
enum SdkError {
SerializationError(string),
SignatureError(string),
KeyError(string),
ValidationError(string)
}WARNING: Test vectors contain deterministic private keys purely for cross-compatibility testing and CI execution. These keys MUST NEVER be used in a production environment.
{
"claim": {
"data": "test_data_123",
"timestamp": 1704067200
},
"canonical_json": "{\"data\":\"test_data_123\",\"timestamp\":1704067200}"
}Input: "Hello, Provncloud!"
Expected: "7c3e8..." (SHA-256)
#[wasm_bindgen]
pub fn wasm_generate_keypair() -> String;
#[wasm_bindgen]
pub fn wasm_compute_hash(data: &[u8]) -> String;
#[wasm_bindgen]
pub fn wasm_sign_claim(claim_json: &str, private_key_hex: &str) -> Result<String, JsValue>;
#[wasm_bindgen]
pub fn wasm_verify_claim(signed_claim_json: &str) -> Result<bool, JsValue>;| Spec | SDK | Changes |
|---|---|---|
| 1.0 | 0.2.0 | Initial release |