MCPcopy Create free account
hub / github.com/base/base / encode_dispute_proof_bytes

Method encode_dispute_proof_bytes

crates/proof/primitives/src/proof_encoder.rs:101–116  ·  view source on GitHub ↗

Encodes a TEE proof into the compact 66-byte format expected by `AggregateVerifier.nullify()`, `challenge()`, and `verifyProposalProof()`. Format: `proofType(1) + signature(65)` These contract entry-points already have `l1Head` stored in CWIA, so the proof bytes do not need to carry `l1OriginHash` or `l1OriginNumber`. The contract slices `proofBytes[1:]` to extract the signature, unlike `initial

(signature: &[u8])

Source from the content-addressed store, hash-verified

99 ///
100 /// Returns an error if the signature is not exactly 65 bytes or has an invalid v-value.
101 pub fn encode_dispute_proof_bytes(signature: &[u8]) -> Result<Bytes, CryptoError> {
102 if signature.len() != ECDSA_SIGNATURE_LENGTH {
103 return Err(CryptoError::InvalidSignatureLength(signature.len()));
104 }
105
106 let mut proof_data = vec![0u8; 1 + ECDSA_SIGNATURE_LENGTH];
107
108 // Byte 0: proof type (TEE = 0)
109 proof_data[0] = PROOF_TYPE_TEE;
110
111 // Bytes 1-65: ECDSA signature with v-value adjusted from 0/1 to 27/28
112 proof_data[1..66].copy_from_slice(&signature[..ECDSA_SIGNATURE_LENGTH]);
113 proof_data[65] = Self::normalize_v(proof_data[65])?;
114
115 Ok(Bytes::from(proof_data))
116 }
117
118 /// Encodes raw ZK proof bytes into the compact format expected by dispute game entry points.
119 ///

Callers

nothing calls this directly

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected