Markus Triska
cbbed310c5
ADDED: format/3, writing formatted output to a stream
...
Both binary and text streams are supported.
2020-05-22 17:23:51 +02:00
Markus Triska
1108c99688
document that lists of integers can be specified if encoding(octet) is used
...
This seems to be a good compromise: The API now strongly encourages
lists of characters, which are ideally suited to represent text, and
also allows lists of bytes if the encoding(octet) option is used.
2020-05-21 13:41:57 +02:00
Markus Triska
93da831ef0
correct mode indication for ed25519_verify/4
...
Noted by @notoria in #545 . Many thanks!
2020-05-21 01:27:06 +02:00
Markus Triska
72bf45912e
"PrivateKey" --> "KeyPair"
2020-05-21 00:14:15 +02:00
Markus Triska
5d94276c4f
remove several mentions of list of bytes in predicate descriptions
...
This is to focus more on the intended core representation of text: In
Prolog, text is ideally represented as a list of characters, and this
is what we want to encourage, especially given Scryer's compact
representation for strings.
For the time being, library(crypto) still also supports lists of bytes in
several predicates. This will likely be removed at some point in the
future. Please use lists of characters to make your code future-proof.
2020-05-21 00:07:42 +02:00
Markus Triska
b43f27030e
require PKCS#8 v2 format for better security
...
Notably, this format requires that the public key also be present.
This format is what ed25519_new_keypair/1 generates, and it is
strongly encouraged for higher security.
2020-05-20 23:55:21 +02:00
Markus Triska
2845f55157
ADDED: ed25519_keypair_public_key/2, relating a key pair to its public key
2020-05-20 23:43:28 +02:00
Markus Triska
e254d84710
clarify format of public key
2020-05-20 23:17:42 +02:00
Markus Triska
0ef7b5488d
ADDED: ed25519_new_keypair/1 to dynamically create a new Ed25519 key pair
2020-05-20 23:11:56 +02:00
Markus Triska
56b04f8df8
use LessSafeKey to simplify the implementation of authenticated encryption
...
The nonce is explicitly specified, and the application programmer
must (and always had to) ensure that it is unique for a given key.
2020-05-20 22:32:39 +02:00
Markus Triska
2d036c6b25
"codes" --> "bytes"
...
Support for lists of bytes may be dropped from library(crypto). Use
lists of characters to make your code future-proof. Lists of
characters will always be supported due to their compactness,
and because Prolog applications should move towards characters.
2020-05-20 22:32:39 +02:00
Markus Triska
ad3be5c848
ADDED: Public key signatures and signature verification with Ed25519
2020-05-20 22:32:39 +02:00
Markus Triska
21b7348c6a
import member/2 from library(lists)
2020-05-19 20:13:06 +02:00
Markus Triska
0bd9831eec
ADDED: phrase_from_file/3 in library(pio)
...
This allows us to specify type(binary), and read from binary files
with DCGs.
2020-05-19 18:52:18 +02:00
Markus Triska
dec2ef70c7
better error handling in crypto_data_hkdf/4
...
Noted by @notoria in #533 . Many thanks!
2020-05-19 18:22:25 +02:00
Markus Triska
d19d8ea770
crypto_data_hkdf/4: do not crash for length > usize::max_value()
...
For now, we fail silently in such cases.
Noted by @notoria in #533 . Many thanks!
2020-05-19 17:31:36 +02:00
Markus Triska
34f7752c0f
use more fixnums in cryptographic routines
2020-05-19 17:03:02 +02:00
Markus Triska
da4d061067
correct option processing in crypto_data_decrypt/6
2020-05-19 17:02:33 +02:00
Markus Triska
85155439be
use Fixnums for bytes in hashing.
...
Suggested by @notoria in #533 . Many thanks!
2020-05-19 16:43:44 +02:00
Markus Triska
dd32e69061
use matching to select the hashing algorithm
...
Suggested by @notoria in #533 . Many thanks!
2020-05-19 16:37:50 +02:00
Markus Triska
9f5322d309
ADDED: Support for BLAKE2 algorithms in crypto_data_hash/3.
2020-05-19 12:44:10 +02:00
Markus Triska
f5c2f6f9e9
ADDED: Support for SHA-3 algorithms in crypto_data_hash/3
2020-05-19 12:10:46 +02:00
Markus Triska
a423eb5323
stronger validation of input lists for cryptographic routines
...
Example:
?- crypto_data_hkdf(Var, 32, Bs, []).
caught: error(instantiation_error,must_be/2)
Reported by @notoria in #527 . Many thanks!
2020-05-18 13:28:52 +02:00
Markus Triska
fd732550d8
crypto_data_hkdf/4: Fail if the length is too long.
...
Due to the way the counter is constructed in the HKDF specification,
the requested output length can be at most 255 times the size of the
digest algorithm's output.
Reported by @notoria in #527 . Many thanks!
2020-05-18 13:21:38 +02:00
Markus Triska
fac7ba70c8
crypto_password_hash/3: fail if the number of iterations is too high
...
Discussed in #527 .
2020-05-18 13:11:39 +02:00
Markus Triska
e9f8b35918
centralize reasoning about encoding
2020-05-18 11:29:35 +02:00
Markus Triska
23034dd4f5
raise instantiation errors for variable encoding
...
Reported by notoria in #527 .
Note that from a declarative perspective, it would indeed be valid to
give answers for both available encodings.
2020-05-18 11:21:38 +02:00
Markus Triska
70ad44adfd
type check for length argument in crypto_data_hkdf/4
...
Reported by @notoria in #527 .
2020-05-18 11:12:59 +02:00
Markus Triska
95ca8a2630
throw instantiation error if the list of options contains a variable ( #523 )
...
Many thanks to @notoria for the test case!
2020-05-18 09:58:09 +02:00
Markus Triska
3855d7ea02
type test for salt in crypto_password_hash/3
2020-05-17 22:01:22 +02:00
Markus Triska
862ae26631
Authenticated encryption in library(crypto), new encoding/1 option for hashes ( #515 )
...
* shorten n_newlines//1
* remove unneeded variable
* ADDED: authenticated encryption and decryption with ChaCha20-Poly1305
* ADDED: encoding/1 option for crypto_data_hash/3 and crypto_data_hkdf/4
2020-05-16 11:51:41 -06:00
Markus Triska
4e69301562
ADDED: Password-based key derivation (PBKDF2) ( #509 )
...
The new predicates crypto_password_hash/[2,3] let you store
passwords safely, and easily verify passwords later.
2020-05-15 10:49:23 -06:00
Markus Triska
50776748a7
ADDED: HMAC-based key derivation (HKDF) via crypto_data_hkdf/4
...
This is useful to generate keys and initialization vectors
from suitable input keying material, so that future predicates
for symmetric encryption can be used with appropriate parameters.
2020-05-14 20:07:59 +02:00
Markus Triska
4084005ee7
ADDED: Reasoning about elliptic curves in library(crypto).
...
This is useful to establish shared secrets, using ECDH key exchange.
Note that CLP(ℤ) goal expansion is currently disabled due to #445 ,
and this slows down the computations considerably for the time being.
2020-05-13 22:44:27 +02:00
Markus Triska
fd761735d4
ADDED: ripemd160 digest algorithm
...
This is used for example for Bitcoin address generation.
2020-05-13 22:36:40 +02:00
Markus Triska
8cd7d08573
ADDED: crypto_data_hash/3, computing cryptographically secure digests
2020-05-13 19:23:09 +02:00
Markus Triska
716fde5784
ADDED: crypto_n_random_bytes/2, creating cryptographically secure random bytes
...
The ring crate is used since it will be needed also for future
predicates in library(crypto).
2020-05-13 00:36:27 +02:00
Markus Triska
d75449ea63
ADDED: ~Nr and ~NR are now available for radix conversions
2020-05-09 19:19:25 +02:00
Markus Triska
a131c93a14
ADDED: Initial version of library(crypto).
2020-05-08 22:33:49 +02:00
Markus Triska
2dfdaaa4ba
disable goal expansion until #445 is resolved
2020-05-04 18:55:52 +02:00
Markus Triska
605c233753
do not project queue/2 attributes to residual goals
2020-05-04 00:54:43 +02:00
Markus Triska
ec6d725587
use ℤ
...
This is now possible thanks to the great contribution by @matt2xu.
Many thanks!
2020-05-02 00:06:16 +02:00
Markus Triska
ca5a5b4392
correct overeager CLP(ℤ) goal expansion
...
For instance, consider:
t(X) :- X #= 1.
We *cannot* expand this to:
?- listing(t/1).
t(A) :-
( integer(A) ->
A=:=A
; ( var(A) ->
true
; true,
clpz:clpz_equal(A,A)
)
).
Also, a new binding *must not* be dragged outside of disjunctions,
since the code may look for example like this:
i(X) :-
( X #= 3
; X #= 4
).
This commit fixes such issues, and still rewrites CLP(ℤ) expressions
as far as possible already at compilation time.
For example:
n(X) :- X #= 1+3.
This is now compiled to (note that 1+3 is evaluated to 4):
?- listing(n/1).
n(A) :-
( integer(A) ->
A=:=4
; ( var(A) ->
A=4
; B=4,
clpz:clpz_equal(A,B)
)
).
Ideally, it should be compiled to:
n(4).
2020-05-01 18:29:00 +02:00
Markus Triska
1dbadbfc35
enable goal expansion for CLP(ℤ) goals
...
Example:
integer_successor(I0, I) :- I #= I0 + 1.
Yielding:
?- listing(integer_successor/2).
integer_successor(A,B) :-
( integer(B) ->
( integer(A) ->
B=:=A+1
; C is B,
clpz:clpz_equal(C,A+1)
)
; ( integer(A) ->
( var(B) ->
B is A+1
; C is A+1,
clpz:clpz_equal(B,C)
)
; clpz:clpz_equal(B,A+1)
)
).
Thus, fast low-level arithmetic is used whenever possible.
2020-04-30 23:09:15 +02:00
Markus Triska
a39f4b4487
correct verify_attributes/3 for variables that have no CLP(ℤ) attribute attached ( #373 )
...
Example:
?- freeze(B, queen_value_truth(C,N,B)), Q #= N #<==> B.
clpz:(Q#=N#<==>B), clpz:(B in 0..1), freeze:freeze(B,queen_value_truth(C,N,B))
; false.
2020-04-30 18:10:09 +02:00
Markus Triska
b499c575bc
include library(arithmetic) in the overview
...
Many thanks to @notoria for these very useful predicates!
2020-04-29 22:06:49 +02:00
Markus Triska
20b76a703a
mention portray_clause/1 and listing/1
2020-04-28 18:27:46 +02:00
Markus Triska
dcc09b7bb5
mention backtrackable and non-backtrackable global variables
2020-04-28 18:22:18 +02:00
Markus Triska
4ea0dee90a
use new nth0/3 from library(lists)
2020-04-28 17:59:49 +02:00
Markus Triska
e61116d35a
use singleton variable, correct a mistake in maplist/8
2020-04-28 17:59:49 +02:00
Markus Triska
f7256c75d5
ADDED: nth0/3, relating indices to list elements
2020-04-28 17:59:49 +02:00
Markus Triska
2696fd1291
small typographic corrections
2020-04-28 17:59:49 +02:00
Markus Triska
b139620fba
use new predicates from library(error) to throw type and domain errors
2020-04-28 17:59:49 +02:00
Markus Triska
5f35dffa34
if_ --> if_/3
2020-04-27 19:53:25 +02:00
Markus Triska
89a4b5a6ff
add more information about Constraint Logic Programming (CLP)
2020-04-27 19:48:46 +02:00
Markus Triska
ff41d6aef9
include the new library(random) in the overview
...
Many thanks to @notoria for this contribution!
2020-04-27 18:44:59 +02:00
Markus Triska
8e1ba58551
use new predicates from library(error)
2020-04-27 18:44:59 +02:00
Markus Triska
2b1692a860
ADDED: library(error): instantiation_error/1, domain_error/3, type_error/3
...
These predicates simplify throwing ISO errors.
2020-04-27 18:44:59 +02:00
Markus Triska
7a2981e21c
include usage advice about probabilistic predicates
2020-04-27 18:44:59 +02:00
Markus Triska
a167bcff5e
add library(cont) to the list
2020-04-26 21:57:37 +02:00
Markus Triska
fb812e6335
add more information about tabling
2020-04-26 21:57:37 +02:00
Markus Triska
b604177ca1
include library(pio) and library(charsio) in the description
2020-04-25 20:12:54 +02:00
Markus Triska
f27597cab5
update toplevel interaction
2020-04-25 20:12:54 +02:00
Markus Triska
40619c8184
ENHANCED: Throw domain errors in char_type/2 for wrong types
...
This is especially important because a few of our names diverge from
ctype(3), and we better inform programmers when the type they are
using is not available at all.
2020-04-25 20:12:54 +02:00
Markus Triska
b0a5df2838
use an anonymous variable
2020-04-25 19:59:46 +02:00
Markus Triska
20fb6d6669
ADDED: library(format) now provides a rudimentary version of listing/1
...
Example:
:- dynamic(a/1).
a(X) :- X = true, b(X).
Yielding:
?- listing(a/1).
%@ a(A) :-
%@ A=true,
%@ b(A).
%@ true.
listing/1 only works for predicates and DCGs that are declared dynamic/1.
2020-04-22 01:53:20 +02:00
Markus Triska
608d661355
portray_clause/1 now correctly tracks variable names ( #376 )
...
Example:
?- portray_clause((A :- B)).
%@ A :-
%@ B.
%@ true
%@ ; ...
Also, change the indentation from 8 to 3 at the express request of @UWN.
2020-04-20 22:53:15 +02:00
Markus Triska
7a3e6e19b1
update comment
2020-04-19 22:36:27 +02:00
Markus Triska
7141fb18c1
ENHANCED: time(Goal) now also reports the time if Goal fails
2020-04-19 21:13:15 +02:00
Markus Triska
23b8a4d364
add entry for time/1
2020-04-19 19:24:22 +02:00
Markus Triska
c0df8cb578
update answer to use the latest toplevel improvements
2020-04-19 19:18:47 +02:00
Markus Triska
4693c23a49
ADDED: library(time), providing time/1 for benchmarking
...
sleep/1 and predicates for reasoning about time stamps should also
be added to this library.
2020-04-19 19:18:47 +02:00
Markus Triska
60f1f1cb3d
Restore the type_error, which was implemented correctly by @notoria.
...
This corrects f28e87b240 :
in_character is a valid type by 7.12.2 Error classification!
2020-04-19 02:15:59 +02:00
Markus Triska
ab3c520006
document ~| format modifier to place a tab stop at this position
...
This works best when used in tandem with ~N+, since it is currently
equivalent to ~0| and does not take the actual text position into account.
However, when using relative positions, this works as intended.
2020-04-19 01:59:16 +02:00
Markus Triska
45ed9405b0
use the most recent improvements
2020-04-19 01:34:13 +02:00
Markus Triska
075ca78dd2
ENHANCED: Delay toplevel output until after the goal succeeds.
...
This is to accommodate goals that are used for their side-effects,
when we are interested in their output.
Examples:
?- portray_clause((a :- a)).
a :-
a.
true
; false.
?- format("hello~w~n", [!]).
hello!
true
; false.
2020-04-19 01:34:03 +02:00
Markus Triska
1713f1222b
reintroduce "n" as a synonym for ";" and " "
2020-04-18 14:16:46 -06:00
Markus Triska
450591d5a9
ENHANCED: the toplevel interaction now supports RETURN as a synonym for "."
...
This is made possible due to the recent improvements by @notoria.
2020-04-18 14:16:46 -06:00
Markus Triska
5c4863dfb1
small simplifications
2020-04-18 14:16:46 -06:00
Markus Triska
f28e87b240
instead of a type error, use a domain error
...
The preceding use of atom_length/2 already ensures that C has the
correct type (i.e., atom). However, its domain may still be wrong,
if its length is greater than 1.
2020-04-18 14:16:46 -06:00
Markus Triska
2d77ef4245
use get_single_char/1
2020-04-18 14:16:46 -06:00
Markus Triska
16e257ea32
ADDED: list_to_set/2, using the first occurrence of each element
...
Example:
?- list_to_set([B,a,b,a,B,A,b,A], Ls).
Ls = [B,a,b,A]
; false.
2020-04-18 14:16:40 -06:00
Markus Triska
e8091d8add
update the toplevel description, incorporating the latest changes
2020-04-18 14:16:40 -06:00
Markus Triska
2ae5472872
reintroduce "n" as a synonym for ";" and " "
2020-04-18 18:09:55 +02:00
Markus Triska
98a32790cd
ENHANCED: the toplevel interaction now supports RETURN as a synonym for "."
...
This is made possible due to the recent improvements by @notoria.
2020-04-18 17:56:37 +02:00
Markus Triska
6dcefcfb71
small simplifications
2020-04-18 17:52:43 +02:00
Markus Triska
1f7e18f2a9
instead of a type error, use a domain error
...
The preceding use of atom_length/2 already ensures that C has the
correct type (i.e., atom). However, its domain may still be wrong,
if its length is greater than 1.
2020-04-18 14:39:30 +02:00
Markus Triska
105e9c8e88
use get_single_char/1
2020-04-18 14:33:11 +02:00
Markus Triska
2c96420bc4
ADDED: list_to_set/2, using the first occurrence of each element
...
Example:
?- list_to_set([B,a,b,a,B,A,b,A], Ls).
Ls = [B,a,b,A]
; false.
2020-04-15 18:04:01 +02:00
Markus Triska
2d1f57e839
update the toplevel description, incorporating the latest changes
2020-04-14 19:24:13 +02:00
Markus Triska
237c855f10
ADDED: group_pairs_by_key/2
...
Pairs must be keysorted and may also contain variables as keys.
Examples:
?- group_pairs_by_key([1-a,1-b,2-c], Ps).
Ps = [1-[a,b],2-[c]].
?- group_pairs_by_key([X-a,X-b,2-c], Ps).
Ps = [X-[a,b],2-[c]].
2020-04-14 00:10:33 +02:00
Markus Triska
ab9b604d02
the workaround is no longer necessary, since #336 is now corrected
2020-04-13 11:32:06 +02:00
Markus Triska
f52c9772a7
also include a newline in portray_clause/1
2020-04-13 01:24:15 +02:00
Markus Triska
208927544d
ADDED: provide a rudimentary version of portray_clause/1
...
At the moment, library(format) seems to be a fitting place.
In the eventual library organization, portray_clause/1 and
related predicates may be moved to their own dedicated library.
2020-04-13 01:04:52 +02:00
Markus Triska
786f0b5ca2
incorporate the latest improvements in the description of partial strings
...
As of 6e4b76a3b4 , the use of
partial_string/3 can be replaced by (=)/2 in this example.
2020-04-12 20:46:22 +02:00
Markus Triska
c9f1a95343
ENHANCED: ~w now supports compound terms, and ~q is now also available
2020-04-12 19:56:01 +02:00
Markus Triska
4d32b6976a
add library(freeze) to make zcompare/3 work
2020-04-08 22:09:59 +02:00
Markus Triska
fac6d54986
extend description of strings and partial strings
...
Also, explain in more detail what this feature means to Prolog
application programmers, and the strategic direction of Scryer.
2020-04-08 21:07:00 +02:00
Markus Triska
e442fddc66
tuples_in/2 now works
2020-04-08 17:49:06 +02:00
Markus Triska
794ceac440
clpz_monotonic/0 --> monotonic/0
2020-04-06 23:05:57 +02:00