Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › crypto/ › Certificate.zig › verifyEd25519
verifyEd25519
Certificate.verifyEd25519
fn verifyEd25519 (
message : []const u8 ,
encoded_sig : []const u8 ,
pub_key_algo : Parsed .PubKeyAlgo ,
encoded_pub_key : []const u8 ,
) !void
File
Code
fn verifyEd25519 (
message : []const u8 ,
encoded_sig : []const u8 ,
pub_key_algo : Parsed .PubKeyAlgo ,
encoded_pub_key : []const u8 ,
) !void {
if (pub_key_algo != .curveEd25519 ) return error .CertificateSignatureAlgorithmMismatch ;
const Ed25519 = crypto .sign .Ed25519 ;
if (encoded_sig .len != Ed25519 .Signature .encoded_length ) return error .CertificateSignatureInvalid ;
const sig = Ed25519 .Signature .fromBytes (encoded_sig [0 ..Ed25519 .Signature .encoded_length ].*);
if (encoded_pub_key .len != Ed25519 .PublicKey .encoded_length ) return error .CertificateSignatureInvalid ;
const pub_key = Ed25519 .PublicKey .fromBytes (encoded_pub_key [0 ..Ed25519 .PublicKey .encoded_length ].*) catch |err | switch (err ) {
error .NonCanonical => return error .CertificateSignatureInvalid ,
};
sig .verify (message , pub_key ) catch |err | switch (err ) {
error .IdentityElement => return error .CertificateSignatureInvalid ,
error .NonCanonical => return error .CertificateSignatureInvalid ,
error .SignatureVerificationFailed => return error .CertificateSignatureInvalid ,
error .InvalidEncoding => return error .CertificateSignatureInvalid ,
error .WeakPublicKey => return error .CertificateSignatureInvalid ,
};
}