Poseidon Signature
The Poseidon Signature we provide is implemented vi a combination of ECC api. Recall that ECDSA signature has the following pesudo code
impl JubjubSignature {
pub fn verify(&self, pk: &BabyJubjubPoint, msghash: &[u64; 4]) {
unsafe {
let r = BabyJubjubPoint::msm(&[
(pk, msghash),
(&self.sig_r, &ONE.0),
(&NEG_BASE, &self.sig_s),
]);
require(r.x.is_zero() && r.y == ONE);
}
}
}Thus to implement the signature on a particular curve, we only need to support the msm host for that curve.
ECC host APIs for Poseidon
We provide the following build-in host APIs for poseidon curve.
extern "C" {
pub fn babyjubjub_sum_new(x: u64);
pub fn babyjubjub_sum_push(x: u64);
pub fn babyjubjub_sum_finalize() -> u64;
}And the reference implementation of msm is
Recall that the ZKWASM guest communicates with host circuits via a serial-like calling convention, thus the above implementation is a serial-like data transmit process as follows.
set the reset flat to the host circuits by babyjubjub_sum_new(true)
transfer the points x, y and scalars
finalize and get the results
Last updated