Module sui::ecdsa_r1
Constants
signature에서 public key를 복구할 수 없으면 발생하는 오류이다.
const EFailToRecoverPubKey: u64 = 0;
signature가 유효하지 않으면 발생하는 오류이다.
const EInvalidSignature: u64 = 1;
ecrecover와 secp256k1_verify에서 유효한 hash 함수 이름이다.
const KECCAK256: u8 = 0;
const SHA256: u8 = 1;
Function secp256r1_ecrecover
@param signature: Secp256r1로 서명된 (r, s, v) 형태의 65바이트 signature이다. RFC6979를 사용한 signature 생성의 참조 구현은 다음과 같다: https://github.com/MystenLabs/fastcrypto/blob/74aec4886e62122a5b769464c2bea5f803cf8ecc/fastcrypto/src/secp256r1/mod.rs 허용되는 v 값은 {0, 1, 2, 3}이다. @param msg: signature가 서명한 대상 메시지이며, hash되지 않은 원시 메시지이다. @param hash: 서명 시 메시지를 hash하는 데 사용한 hash 함수 이름을 나타내는 u8이다.
signature가 유효하면 대응하는 복구된 Secpk256r1 public key를 반환하고, 그렇지 않으면 오류를 발생시킨다. 이는 Ethereum의 ecrecover와 유사하며 Secp256r1 signature에만 적용할 수 있다.
EFailToRecoverPubKey 또는 EInvalidSignature로 중단될 수 있다.
public fun secp256r1_ecrecover(signature: &vector<u8>, msg: &vector<u8>, hash: u8): vector<u8>
Implementation
public native fun secp256r1_ecrecover(
signature: &vector<u8>,
msg: &vector<u8>,
hash: u8,
): vector<u8>;
Function secp256r1_verify
@param signature: Secp256r1로 서명된 (r, s) 형태의 64바이트 signature이다. 이는 recovery id가 없는 비복구형 signature이다. RFC6979를 사용한 signature 생성의 참조 구현은 다음과 같다: https://github.com/MystenLabs/fastcrypto/blob/74aec4886e62122a5b769464c2bea5f803cf8ecc/fastcrypto/src/secp256r1/mod.rs @param public_key: signature를 검증할 public key이다. @param msg: signature가 서명한 대상 메시지이며, hash되지 않은 원시 메시지이다. @param hash: 서명 시 메시지를 hash하는 데 사용한 hash 함수 이름을 나타내는 u8이다.
signature가 pubkey와 hash된 메시지에 대해 유효하면 true를 반환한다. 그렇지 않으면 false를 반환한다.
public fun secp256r1_verify(signature: &vector<u8>, public_key: &vector<u8>, msg: &vector<u8>, hash: u8): bool
Implementation
public native fun secp256r1_verify(
signature: &vector<u8>,
public_key: &vector<u8>,
msg: &vector<u8>,
hash: u8,
): bool;