Markus Triska
41a751e7f5
ADDED: Provisional support for (#=)/3 and (#<)/3.
...
These predicates are intended for constructs from library(reif), such
as if_/3. For the time being, they are defined here. If you have any
recommendations or comments regarding the best location of these
predicates, or need more of them, please file an issue.
Suggested by @Qqwy in https://github.com/triska/clpz/issues/12 .
Many thanks!
2020-11-08 09:26:50 +01:00
Markus Triska
83350f8866
use "r" interactive specifier
2020-10-03 17:13:17 +02:00
Markus Triska
b4ccd889af
refer to new tools directory
2020-10-03 09:59:31 +02:00
Markus Triska
35a3f2dc91
ADDED: showterm.el and showterm.pl to draw terms as trees in Emacs
2020-10-03 09:56:26 +02:00
Markus Triska
2e295e354a
DOC: Development environment recommendations.
2020-10-01 21:15:40 +02:00
Markus Triska
46dfaa5b28
ENHANCED: library(files): Error handling if requested files do not exist.
...
We now throw exceptions instead of failing silently, or even crashing
when using file_size/2 etc. with nonexistent files.
2020-09-13 10:23:23 +02:00
Markus Triska
5f3ab823fd
FIXED: format_//2: Keep different variables distinct.
...
Example:
?- phrase(format_("~w~w", [_,_]), Ls).
%@ Ls = "AB"
%@ ; false.
2020-09-05 09:58:49 +02:00
Markus Triska
78656d220b
FIXED: reliably write all characters when using format/3
...
This addresses #693 .
Many thanks to @notoria for a brilliant test case, and the
suggestion of this correction!
2020-09-02 19:29:04 +02:00
Markus Triska
79cb4cd6a5
ADDED: First version of call_nth/2.
...
A thread-safe implementation is possible for example with
'$nb_setarg'/3 (see #390 ).
2020-08-24 19:29:08 +02:00
Markus Triska
cc77ef680d
dif/2: Omit entailed residual goals, if the arguments are not unifiable.
...
This addresses #135 .
2020-08-22 17:50:15 +02:00
Markus Triska
e75ebd9b6e
dif/2: Succeed unconditionally if the arguments are not unifiable.
...
This addresses one part of #135 .
2020-08-22 17:50:15 +02:00
Markus Triska
e185b626bd
FIXED: CLP(B): Delay BDD restriction until after the instantiation.
...
This is necessary to actually take the new value into account.
Example:
?- sat(A*B>=C*D), A=1,B=0,C=1,D=1.
false.
This addresses #670 .
2020-08-12 19:51:25 +02:00
Markus Triska
099d9aaca6
library(sgml): Correctly parse XML leaf nodes that are not text nodes.
...
Example:
?- load_xml("<schemaRef type=\"simple\"/>", Node, []).
Node = [element(schemaRef,[type="simple"],[])].
This is necessary for example to parse XBRL files. See #665 .
2020-08-11 21:20:33 +02:00
Markus Triska
ad8e2ad4f6
omit internal attributes in residual goals when using taut/2
...
Examples:
?- taut(X=:=X,1).
clpb:sat(X=:=X)
; false.
?- taut(X=\=X,0).
clpb:sat(X=:=X)
; false.
2020-08-11 20:49:10 +02:00
Markus Triska
c55cc3c472
ensure proper lengths of key and initialization vector
...
This avoids crashes when using unsuitable lengths.
2020-08-06 23:27:49 +02:00
Markus Triska
674483a4c6
remove entailed constraint
2020-08-06 23:17:08 +02:00
Markus Triska
a16f84560d
use self.deref(...) (see #653 )
2020-08-06 20:12:57 +02:00
Markus Triska
1b4500339e
use atom_argument_to_string
2020-08-06 20:12:23 +02:00
Markus Triska
2d3f1e51ec
shorten, and increase readability
2020-08-05 21:49:46 +02:00
Markus Triska
1c23336cff
use "octet" as a string literal, reducing the number of arguments
2020-08-05 20:21:46 +02:00
Markus Triska
a622ffddfe
ADDED: library(crypto): Support for additional authenticated data (AAD).
...
Additional authenticated data can now be specified with the new
aad(Chars) option for encryption and decryption. It is authenticated,
but not encrypted.
2020-08-05 20:09:07 +02:00
Markus Triska
32c612b747
ADDED: library(crypto): ECDH key exchange over Curve25519 (X25519)
2020-07-29 23:51:11 +02:00
Markus Triska
dcc4b91b35
ENHANCED: flush output for impure I/O (format/[2,3], portray_clause/1 etc.)
...
Without this, we do not get a (timely) prompt in cases like:
?- format("press a key: ", []), get_single_char(C).
whereas for example write/1 already works in such cases:
?- write('press a key: '), get_single_char(C).
press a key:
2020-07-25 09:49:02 +02:00
Markus Triska
928c9c9aad
throw an error if a character cannot be encoded
2020-07-23 00:35:23 +02:00
Markus Triska
4a90f13dee
better error handling for options
2020-07-23 00:27:31 +02:00
Markus Triska
61dddcee3f
use newly available chars_base64/3
2020-07-22 20:35:48 +02:00
Markus Triska
4c510001ce
ADDED: chars_base64/3 for efficient bidirectional Base64 conversion.
2020-07-22 20:35:48 +02:00
Markus Triska
2768beec4c
ADDED: path_segments/2 for portable reasoning about path components.
...
The platform-specific directory separator is taken into account.
The clean representation of segments as a list simplifies reasoning.
2020-07-19 12:32:01 +02:00
Markus Triska
c9a69263b6
DOC: add more links to libraries, and include iso_ext in the enumeration
2020-07-18 08:12:26 +02:00
Markus Triska
17dd9239b6
ADDED: file_creation_time/2 and file_access_time/2.
...
The code can be simplified once if- and while-let-chains are available:
https://github.com/rust-lang/rust/issues/53667
2020-07-17 18:48:39 +02:00
Markus Triska
8668aee7fd
ENHANCED: Reorder fields in time stamps so that (@<)/2 is meaningful.
2020-07-16 23:40:03 +02:00
Markus Triska
4f386b3e5e
ADDED: file_modification_time/2, obtaining a time stamp.
...
This addresses a remaining aspect of #511 .
2020-07-16 23:40:03 +02:00
Markus Triska
0f4667d942
ADDED: path_canonical/2, obtaining the canonical absolute path.
...
This addresses a remaining aspect of #511 .
2020-07-15 20:43:34 +02:00
Markus Triska
94e9e17c79
ADDED: working_directory/2, addressing a remaining aspect of #511
2020-07-14 23:05:29 +02:00
Markus Triska
5134e64cae
ADDED: delete_file/1, addressing a remaining aspect of #511
2020-07-14 22:21:46 +02:00
Markus Triska
b227e160f0
mention symmetric encryption and ChaCha20-Poly1305
2020-07-12 11:59:34 +02:00
Markus Triska
88a2b82f7e
ENHANCED: library(crypto): Retain the compact representation of strings.
...
This avoids the costly (in terms of space requirements!) conversion of
compact lists of characters to lists of integers, making hashing, HKDF,
encryption, decryption, signing and signature verification an order of
magnitude more efficient (primarily in terms of space, also in time).
This makes library(crypto) suitable to process also very large files.
2020-07-12 11:54:37 +02:00
Markus Triska
0fa8feb475
use newly available character type in must_be/2
2020-07-11 21:00:25 +02:00
Markus Triska
eb872f8fca
ADDED: library(os), reasoning about environment variables.
...
Together with library(files), this addresses #511 .
2020-07-11 21:00:25 +02:00
Markus Triska
65f200e02c
directory_files/2: throw representation error if into_string() fails
...
Suggested by @notoria in #606 . Many thanks!
2020-06-24 23:30:40 +02:00
Markus Triska
aa9432e24f
comment on indexing, addressing a comment by @pmoura in #606
...
If indexing is needed for lists of characters, it should be added to
the engine.
2020-06-24 22:29:34 +02:00
Markus Triska
30d1585468
ADDED: library(files), for reasoning about files and directories.
2020-06-24 22:29:34 +02:00
Markus Triska
bcd6d4e8a7
library(format) is not used in this example
2020-06-21 09:46:05 +02:00
Markus Triska
32eb896c56
ADDED: load_xml/3 to load XML files from streams, files and strings.
2020-06-21 09:45:37 +02:00
Markus Triska
b3c9fb2fea
import member/2 from library(lists)
...
This is needed when processing redirects.
2020-06-20 19:07:43 +02:00
Markus Triska
d66ea07ba4
ADDED: library(xpath) for convenient analysis of HTML and XML documents.
2020-06-20 18:08:11 +02:00
Markus Triska
79829cb6d2
ADDED: library(sgml), providing load_html/3 to parse HTML documents
2020-06-19 16:40:01 +02:00
Markus Triska
5eda2dfe0e
put_char/[1,2]: throw type errors for atoms that are not characters
...
Example:
?- put_char(hello).
%@ caught: error(type_error(character,hello),put_char/2)
2020-06-18 00:15:00 +02:00
Markus Triska
19acd608a5
ADDED: library(http/http_open), opening HTTP and HTTPS streams for reading
...
Example:
?- http_open("https://github.com/mthom/scryer-prolog ", Stream, []),
length(Ls, 10),
maplist(get_char(Stream), Ls).
Yielding:
%@ Stream = '$stream'(0x7fba4c59ef10), Ls = "\n\n\n\n\n<!DOC"
%@ ; false.
2020-06-17 20:10:22 +02:00
Markus Triska
8958ea036e
ENHANCED: much faster format/3 for text streams
...
This is now also used by format/2 to emit output on the terminal,
and significantly speeds up toplevel output of long strings.
2020-06-16 21:13:03 +02:00
Markus Triska
10a0f708b9
use format/3 to benefit from efficiency improvements
2020-06-14 10:51:24 +02:00
Markus Triska
409d3c168d
ENHANCED: faster format/3 when writing to binary streams
...
This is also more secure, since it does not change the atom table
and therefore leaves little trace of what was processed.
2020-06-14 10:43:25 +02:00
Markus Triska
f910e013a6
use take() for extra fast processing of binary files
...
Suggested by @notoria in #589 . Many thanks!
2020-06-13 16:47:46 +02:00
Markus Triska
5f1b03261c
better naming: str --> string
...
Suggested by @notoria in #589 . Many thanks!
2020-06-13 16:47:46 +02:00
Markus Triska
862197fc96
explain .scryerrc configuration file
2020-06-13 16:47:02 +02:00
Markus Triska
44ebd894d5
ADDED: portray_clause/2, writing to a specified stream.
2020-06-13 16:45:47 +02:00
Markus Triska
b85ff7db36
ENHANCED: Read more characters at once, significantly speeding up library(pio).
2020-06-13 16:25:41 +02:00
Markus Triska
22fd216de5
ADDED: read_line_to_chars/3, reading up to and including "\n" from a stream, yielding a list difference.
...
This works for both binary and text streams.
2020-06-13 09:14:44 +02:00
Markus Triska
d96ea6b815
include library(pio) and library(charsio) in the itemization
2020-06-12 00:02:41 +02:00
Markus Triska
40c3e31955
ENHANCED: phrase_from_file/[2,3] now read the file lazily.
...
This allows processing extremely large files. In addition, the
efficient string representation helps to reduce memory usage.
These features unleash the full power of Prolog for text processing,
the exact use case Prolog was designed for.
2020-06-12 00:02:41 +02:00
Markus Triska
2fc887724b
ADDED: format_time//2 for describing strings involving dates and times
...
current_time/1 yields the current system time as an opaque time stamp.
2020-06-11 00:55:38 +02:00
Markus Triska
184ef94e7e
ENHANCED: throw Prolog exception on expired certificates
...
Example:
?- socket_client_open('expired.badssl.com':443, S, [tls(true)]).
caught: error(permission_error(open,source_sink,'expired.badssl.com'),socket_client_open/3)
2020-06-09 23:01:28 +02:00
Markus Triska
7b30daf88d
ADDED: Encrypted client connections in library(sockets) via new option tls/1.
...
Use tls(true) to negotiate an encrypted network connection via TLS.
2020-06-09 07:43:29 +02:00
Markus Triska
d5e76da475
ADDED: type checks for type boolean
2020-06-08 00:41:47 +02:00
Markus Triska
c22816de08
type check for ~d and ~D specifiers
2020-06-08 00:09:55 +02:00
Markus Triska
9bb851d437
ENHANCED: format_//2 now evaluates arithmetic expressions for ~d, ~D, ~f, ~r and ~R
...
Example:
?- phrase(format_("~d", [1+2]), Cs).
Cs = "3"
; false.
2020-06-08 00:09:55 +02:00
Markus Triska
c8a9f8dcf5
better domain error in format_//2
...
Example:
?- format("", [hello]).
caught: error(domain_error(empty_list,[hello]),format_//2)
2020-06-07 23:59:37 +02:00
Markus Triska
e8653ffe32
add type check for scalar argument in crypto_curve_scalar_mult/4
...
Suggested by @notoria in #576 . Many thanks!
2020-06-07 18:51:13 +02:00
Markus Triska
5499df418a
use secp256k1 in the example
2020-06-07 11:04:24 +02:00
Markus Triska
b586618411
ENHANCED: Faster Rust-based crypto_curve_scalar_mult/4 using OpenSSL.
2020-06-07 11:04:24 +02:00
Markus Triska
7cc92ec1c1
ADDED: Logo.
...
Motivation and considerations:
- A Scryer certainly needs a raven. Ravens are among the most
intelligent animals on earth.
- When writing Prolog programs, a few strokes are often enough.
- Purple is the colour most associated with magic and royalty,
indicating the almost surreal and pure features provided by Scryer,
in the lineage of Marseille Prolog.
- The shape of the silhouette looks a bit like an "S" for "Scryer".
- A square which surrounds the image is traditionally associated with
finishing a proof (square, Latin "quadratum", has the same starting
letters as "quod erat demonstrandum").
I call this raven: *Cryer*. Cryer is an archaic spelling for "crier",
an officer who makes public announcements in a court of justice.
The Prolog top-level likewise makes announcements about what is true.
2020-05-26 22:13:51 +02:00
Markus Triska
b0df981b01
ADDED: halt/1, halting with specified exit code
2020-05-23 19:28:17 +02:00
Markus Triska
48c0b0ab3c
ENHANCED: Faster format/3 for binary streams.
...
This speeds up web servers considerably when sending binary files.
2020-05-22 17:30:29 +02:00
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