Verify offchain program
Example program
// The 'verify_offchain' program.
program verify_offchain.aleo {
struct Credentials {
issuer: address,
subject: address,
dob: u32,
nationality: field,
expiry: u32
}
// msg and r are used to construct a public commitment for ownership verification
// Any message works as long the prover is able to open the commitment
transition verify(
msg: field,
r: scalar,
sig: signature,
public issuer: address,
dob: u32,
nationality: field,
expiry: u32
) -> public field {
let creds: Credentials = Credentials {
issuer: issuer,
subject: self.signer,
dob: dob,
nationality: nationality,
expiry: expiry
};
let res: bool = signature::verify(sig, creds.issuer, Poseidon2::hash_to_field(creds));
assert_eq(res, true);
// Return the commitment publicly
return BHP256::commit_to_field(msg, r);
}
}Last updated