fix(ecash): cast usize to u64 in to_bytes() for 32-bit platform compatibility (#6528)
VerificationKeyAuth::to_bytes() and SecretKeyAuth::to_bytes() used usize::to_le_bytes() to serialize vector lengths, producing 4 bytes on 32-bit and 8 bytes on 64-bit. Since from_bytes() always reads 8 bytes (u64), this caused ZK proof challenge hash mismatches when a 32-bit client's proof was verified by a 64-bit gateway, resulting in "the provided ticket failed to get verified" on all 32-bit platforms.
This commit is contained in:
@@ -112,7 +112,7 @@ impl SecretKeyAuth {
|
||||
let ys_len = self.ys.len();
|
||||
let mut bytes = Vec::with_capacity(8 + (ys_len + 1) * 32);
|
||||
bytes.extend_from_slice(&self.x.to_bytes());
|
||||
bytes.extend_from_slice(&ys_len.to_le_bytes());
|
||||
bytes.extend_from_slice(&(ys_len as u64).to_le_bytes());
|
||||
for y in self.ys.iter() {
|
||||
bytes.extend_from_slice(&y.to_bytes())
|
||||
}
|
||||
@@ -337,7 +337,7 @@ impl VerificationKeyAuth {
|
||||
|
||||
bytes.extend_from_slice(&self.alpha.to_affine().to_compressed());
|
||||
|
||||
bytes.extend_from_slice(&beta_g1_len.to_le_bytes());
|
||||
bytes.extend_from_slice(&(beta_g1_len as u64).to_le_bytes());
|
||||
|
||||
for beta_g1 in self.beta_g1.iter() {
|
||||
bytes.extend_from_slice(&beta_g1.to_affine().to_compressed())
|
||||
|
||||
Reference in New Issue
Block a user