Skip to content

Latest commit

 

History

History
141 lines (56 loc) · 3.46 KB

File metadata and controls

141 lines (56 loc) · 3.46 KB

Module 0x3::rs256

Constants

const ErrorInvalidHashType: u64 = 3;

const ErrorInvalidPubKey: u64 = 2;

const ErrorInvalidSignature: u64 = 1;

const SHA256: u8 = 0;

const ErrorInvalidMessageLength: u64 = 4;

Maximum exponent (e) length (bytes) for RSASSA-PKCS1-V1_5 with SHA-256 (RS256)

Minimum exponent (e) length (bytes) for RSASSA-PKCS1-V1_5 with SHA-256 (RS256)

Minimum modulus (n) length (bits) for RSASSA-PKCS1-V1_5 with SHA-256 (RS256)

Message length for the Sha2-256 hash function

const SHA256_MESSAGE_LENGTH: u64 = 32;

Function sha256

public fun sha256(): u8

Function verify

Verifies a RSA signature from public modulus (n) and public exponent (e) over RSASSA-PKCS1-V1_5 with SHA-256 (RS256). The message will be the original message with hashing in-function.

public fun verify(signature: &vector<u8>, n: &vector<u8>, e: &vector<u8>, msg: &vector<u8>): bool

Function verify_prehash

Verifies a RSA signature from public modulus (n) and public exponent (e) over RSASSA-PKCS1-V1_5 with SHA-256 (RS256). The message will be the hashed using SHA256 before the verification.

public fun verify_prehash(signature: &vector<u8>, n: &vector<u8>, e: &vector<u8>, msg: &vector<u8>, hash_type: u8): bool