ADDED: Public key signatures and signature verification with Ed25519
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
and strings have the advantage that the atom table remains unmodified.
|
||||
|
||||
Especially for cryptographic applications, it as an advantage that
|
||||
using strings leaves little trace of what was processed in the system,
|
||||
using strings leaves little trace of what was processed in the system.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
:- module(crypto,
|
||||
@@ -21,6 +21,8 @@
|
||||
crypto_password_hash/3, % +Password, -Hash, +Options
|
||||
crypto_data_encrypt/6, % +PlainText, +Algorithm, +Key, +IV, -CipherText, +Options
|
||||
crypto_data_decrypt/6, % +CipherText, +Algorithm, +Key, +IV, -PlainText, +Options
|
||||
ed25519_sign/4, % +PrivateKey, +Data, -Signature, +Options
|
||||
ed25519_verify/4, % +PublicKey, +Data, -Signature, +Options
|
||||
crypto_name_curve/2, % +Name, -Curve
|
||||
crypto_curve_order/2, % +Curve, -Order
|
||||
crypto_curve_generator/2, % +Curve, -Generator
|
||||
@@ -624,6 +626,44 @@ encoding_bytes(utf8, Cs, Bs) :-
|
||||
; domain_error(encryption_encoding, Cs, crypto)
|
||||
).
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Digital signatures with Ed25519
|
||||
===============================
|
||||
|
||||
ed25519_sign(+Key, +Data, -Signature, +Options)
|
||||
|
||||
Key and Data must be lists of characters. Key is a private key in
|
||||
PKCS#8 (v1 or v2) DER format. Sign Data with Key, yielding
|
||||
Signature as a list of hexadecimal characters.
|
||||
|
||||
|
||||
ed25519_verify(+Key, +Data, +Signature, +Options)
|
||||
|
||||
Key and Data must be lists of characters. Key is a public key in
|
||||
PKCS#8 DER format. Succeeds if Data was signed with the private key
|
||||
corresponding to Key, where Signature is a list of hexadecimal
|
||||
characters as generated by ed25519_sign/4. Fails otherwise.
|
||||
|
||||
|
||||
Currently, the only option for both predicates is:
|
||||
|
||||
- encoding(+Encoding)
|
||||
The default encoding of Data is utf8. The alternative is octet,
|
||||
which treats Data as a list of raw bytes.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
ed25519_sign(Key0, Data0, Signature, Options) :-
|
||||
options_data_bytes(Options, Data0, Data),
|
||||
encoding_bytes(octet, Key0, Key),
|
||||
'$ed25519_sign'(Key, Data, Signature0),
|
||||
hex_bytes(Signature, Signature0).
|
||||
|
||||
ed25519_verify(Key0, Data0, Signature0, Options) :-
|
||||
options_data_bytes(Options, Data0, Data),
|
||||
encoding_bytes(octet, Key0, Key),
|
||||
hex_bytes(Signature0, Signature),
|
||||
'$ed25519_verify'(Key, Data, Signature).
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Modular multiplicative inverse.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user