use "octet" as a string literal, reducing the number of arguments
This commit is contained in:
@@ -713,10 +713,10 @@ impl SystemClauseType {
|
|||||||
("$crypto_data_encrypt", 7) => Some(SystemClauseType::CryptoDataEncrypt),
|
("$crypto_data_encrypt", 7) => Some(SystemClauseType::CryptoDataEncrypt),
|
||||||
("$crypto_data_decrypt", 6) => Some(SystemClauseType::CryptoDataDecrypt),
|
("$crypto_data_decrypt", 6) => Some(SystemClauseType::CryptoDataDecrypt),
|
||||||
("$crypto_curve_scalar_mult", 5) => Some(SystemClauseType::CryptoCurveScalarMult),
|
("$crypto_curve_scalar_mult", 5) => Some(SystemClauseType::CryptoCurveScalarMult),
|
||||||
("$ed25519_sign", 5) => Some(SystemClauseType::Ed25519Sign),
|
("$ed25519_sign", 4) => Some(SystemClauseType::Ed25519Sign),
|
||||||
("$ed25519_verify", 5) => Some(SystemClauseType::Ed25519Verify),
|
("$ed25519_verify", 4) => Some(SystemClauseType::Ed25519Verify),
|
||||||
("$ed25519_new_keypair", 1) => Some(SystemClauseType::Ed25519NewKeyPair),
|
("$ed25519_new_keypair", 1) => Some(SystemClauseType::Ed25519NewKeyPair),
|
||||||
("$ed25519_keypair_public_key", 3) => Some(SystemClauseType::Ed25519KeyPairPublicKey),
|
("$ed25519_keypair_public_key", 2) => Some(SystemClauseType::Ed25519KeyPairPublicKey),
|
||||||
("$curve25519_scalar_mult", 3) => Some(SystemClauseType::Curve25519ScalarMult),
|
("$curve25519_scalar_mult", 3) => Some(SystemClauseType::Curve25519ScalarMult),
|
||||||
("$load_html", 3) => Some(SystemClauseType::LoadHTML),
|
("$load_html", 3) => Some(SystemClauseType::LoadHTML),
|
||||||
("$load_xml", 3) => Some(SystemClauseType::LoadXML),
|
("$load_xml", 3) => Some(SystemClauseType::LoadXML),
|
||||||
|
|||||||
@@ -651,19 +651,19 @@ ed25519_new_keypair(Pair) :-
|
|||||||
|
|
||||||
ed25519_keypair_public_key(Pair, PublicKey) :-
|
ed25519_keypair_public_key(Pair, PublicKey) :-
|
||||||
must_be_byte_chars(Pair, ed25519_keypair_public_key),
|
must_be_byte_chars(Pair, ed25519_keypair_public_key),
|
||||||
'$ed25519_keypair_public_key'(Pair, octet, PublicKey).
|
'$ed25519_keypair_public_key'(Pair, PublicKey).
|
||||||
|
|
||||||
ed25519_sign(Key, Data0, Signature, Options) :-
|
ed25519_sign(Key, Data0, Signature, Options) :-
|
||||||
must_be_byte_chars(Key, ed25519_sign),
|
must_be_byte_chars(Key, ed25519_sign),
|
||||||
options_data_chars(Options, Data0, Data, Encoding),
|
options_data_chars(Options, Data0, Data, Encoding),
|
||||||
'$ed25519_sign'(Key, octet, Data, Encoding, Signature0),
|
'$ed25519_sign'(Key, Data, Encoding, Signature0),
|
||||||
hex_bytes(Signature, Signature0).
|
hex_bytes(Signature, Signature0).
|
||||||
|
|
||||||
ed25519_verify(Key, Data0, Signature0, Options) :-
|
ed25519_verify(Key, Data0, Signature0, Options) :-
|
||||||
must_be_byte_chars(Key, ed25519_verify),
|
must_be_byte_chars(Key, ed25519_verify),
|
||||||
options_data_chars(Options, Data0, Data, Encoding),
|
options_data_chars(Options, Data0, Data, Encoding),
|
||||||
hex_bytes(Signature0, Signature),
|
hex_bytes(Signature0, Signature),
|
||||||
'$ed25519_verify'(Key, octet, Data, Encoding, Signature).
|
'$ed25519_verify'(Key, Data, Encoding, Signature).
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
X25519: ECDH key exchange over Curve25519
|
X25519: ECDH key exchange over Curve25519
|
||||||
|
|||||||
@@ -5658,8 +5658,7 @@ impl MachineState {
|
|||||||
self.unify(self[temp_v!(1)], complete_string);
|
self.unify(self[temp_v!(1)], complete_string);
|
||||||
}
|
}
|
||||||
&SystemClauseType::Ed25519KeyPairPublicKey => {
|
&SystemClauseType::Ed25519KeyPairPublicKey => {
|
||||||
let encoding = self.atom_argument_to_string(2);
|
let bytes = self.string_encoding_bytes(1, "octet");
|
||||||
let bytes = self.string_encoding_bytes(1, &encoding);
|
|
||||||
|
|
||||||
let key_pair = match signature::Ed25519KeyPair::from_pkcs8(&bytes) {
|
let key_pair = match signature::Ed25519KeyPair::from_pkcs8(&bytes) {
|
||||||
Ok(kp) => { kp }
|
Ok(kp) => { kp }
|
||||||
@@ -5671,12 +5670,12 @@ impl MachineState {
|
|||||||
self.heap.put_complete_string(&buffer)
|
self.heap.put_complete_string(&buffer)
|
||||||
};
|
};
|
||||||
|
|
||||||
self.unify(self[temp_v!(3)], complete_string);
|
self.unify(self[temp_v!(2)], complete_string);
|
||||||
}
|
}
|
||||||
&SystemClauseType::Ed25519Sign => {
|
&SystemClauseType::Ed25519Sign => {
|
||||||
let key = self.string_encoding_bytes(1, "octet");
|
let key = self.string_encoding_bytes(1, "octet");
|
||||||
let encoding = self.atom_argument_to_string(4);
|
let encoding = self.atom_argument_to_string(3);
|
||||||
let data = self.string_encoding_bytes(3, &encoding);
|
let data = self.string_encoding_bytes(2, &encoding);
|
||||||
|
|
||||||
let key_pair = match signature::Ed25519KeyPair::from_pkcs8(&key) {
|
let key_pair = match signature::Ed25519KeyPair::from_pkcs8(&key) {
|
||||||
Ok(kp) => { kp }
|
Ok(kp) => { kp }
|
||||||
@@ -5688,14 +5687,14 @@ impl MachineState {
|
|||||||
let sig_list =
|
let sig_list =
|
||||||
Addr::HeapCell(self.heap.to_list(sig.as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize)))));
|
Addr::HeapCell(self.heap.to_list(sig.as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize)))));
|
||||||
|
|
||||||
self.unify(self[temp_v!(5)], sig_list);
|
self.unify(self[temp_v!(4)], sig_list);
|
||||||
}
|
}
|
||||||
&SystemClauseType::Ed25519Verify => {
|
&SystemClauseType::Ed25519Verify => {
|
||||||
let key = self.string_encoding_bytes(1, "octet");
|
let key = self.string_encoding_bytes(1, "octet");
|
||||||
let encoding = self.atom_argument_to_string(4);
|
let encoding = self.atom_argument_to_string(3);
|
||||||
let data = self.string_encoding_bytes(3, &encoding);
|
let data = self.string_encoding_bytes(2, &encoding);
|
||||||
let stub = MachineError::functor_stub(clause_name!("ed25519_verify"), 5);
|
let stub = MachineError::functor_stub(clause_name!("ed25519_verify"), 5);
|
||||||
let signature = self.integers_to_bytevec(temp_v!(5), stub);
|
let signature = self.integers_to_bytevec(temp_v!(4), stub);
|
||||||
|
|
||||||
let peer_public_key = signature::UnparsedPublicKey::new(&signature::ED25519, &key);
|
let peer_public_key = signature::UnparsedPublicKey::new(&signature::ED25519, &key);
|
||||||
match peer_public_key.verify(&data, &signature) {
|
match peer_public_key.verify(&data, &signature) {
|
||||||
|
|||||||
Reference in New Issue
Block a user