chez-libs

Artifact Content
Login

Artifact 85a8b4122853e51456aa12282ff4e46b98d0cb54:

Wiki page [(crypto tweetnacl)] by murphy 2016-05-22 10:27:17.
D 2016-05-22T10:27:17.340
L (crypto\stweetnacl)
P 2a3557c4ae567e09fff594558fa2a6116afead8b
U murphy
W 4378
<h1>TweetNaCl Bindings</h1>

<h2>Synopsis</h2>

<code>(import (crypto tweetnacl))</code>

Bindings to the [https://tweetnacl.cr.yp.to/|TweetNaCl] library of cryptographic operations.

<h2>Keys</h2>

<h3>record: <code>key</code></h3>
<h3>procedure: <code>(key? <i>any</i>)</code></h3>
<h3>procedure: <code>(make-key <i>algorithm</i> <i>public</i> <i>secret</i>)</code></h3>
<h3>procedure: <code>(key-algorithm <i>key</i>)</code></h3>
<h3>procedure: <code>(public-key <i>key</i>)</code></h3>
<h3>procedure: <code>(secret-key <i>key</i>)</code></h3>

Keys are represented by record instances that hold an algorithm name, a public key bytevector and a secret key bytevector. Depending on the algorithm and intended use of the key, either the public or secret component may be <tt>#f</tt>.

<h3>procedure: <code>(check-key <i>who</i> <i>algorithm</i> <i>any</i>)</code></h3>

Ensures that the given value is a key with the given algorithm name and returns the key. If the value does not pass the check, an error condition is raised that contains a <tt>&who</tt> condition indicating the given location.

<h2>Asymmetric Boxes</h2>

<h3>constant: <code>asymmetric-box-algorithm</code></h3>

The name of the asymmetric box algorithm.

<h3>constant: <code>asymmetric-box-publickeybytes</code></h3>
<h3>constant: <code>asymmetric-box-secretkeybytes</code></h3>
<h3>constant: <code>asymmetric-box-noncebytes</code></h3>

Byte lengths of algorithm parameters.

<h3>procedure: <code>(make-asymmetric-box-key)</code></h3>
<h3>procedure: <code>(make-asymmetric-box-key <i>port</i>)</code></h3>

Generate a new keypair using entropy from the given port or from <tt>(current-entropy-port)</tt>.

<h3>procedure: <code>((asymmetric-box <i>pk</i> <i>sk</i>) <i>data</i> <i>nonce</i>)</code></h3>
<h3>procedure: <code>((asymmetric-unbox <i>pk</i> <i>sk</i>) <i>data</i> <i>nonce</i>)</code></h3>

Perform key agreement and return boxing and unboxing procedures.

<h2>Asymmetric Signatures</h2>

<h3>constant: <code>asymmetric-sign-algorithm</code></h3>

The name of the asymmetric signature algorithm.

<h3>constant: <code>asymmetric-sign-publickeybytes</code></h3>
<h3>constant: <code>asymmetric-sign-secretkeybytes</code></h3>

Byte lengths of algorithm parameters.

<h3>procedure: <code>(make-asymmetric-sign-key)</code></h3>
<h3>procedure: <code>(make-asymmetric-sign-key <i>port</i>)</code></h3>

Generate a new keypair using entropy from the given port or from <tt>(current-entropy-port)</tt>.

<h3>procedure: <code>((asymmetric-sign <i>sk</i>) <i>data</i>)</code></h3>
<h3>procedure: <code>((asymmetric-verify <i>pk</i>) <i>data</i>)</code></h3>

Create signature and verification procedures.

<h2>Symmetric Boxes</h2>

<h3>constant: <code>symmetric-box-algorithm</code></h3>

The name of the symmetric box algorithm.

<h3>constant: <code>symmetric-box-keybytes</code></h3>
<h3>constant: <code>symmetric-box-noncebytes</code></h3>

Byte lengths of algorithm parameters.

<h3>procedure: <code>(make-symmetric-box-key)</code></h3>
<h3>procedure: <code>(make-symmetric-box-key <i>port</i>)</code></h3>

Generate a new key using entropy from the given port or from <tt>(current-entropy-port)</tt>.

<h3>procedure: <code>((symmetric-box <i>k</i>) <i>data</i> <i>nonce</i>)</code></h3>
<h3>procedure: <code>((symmetric-unbox <i>k</i>) <i>data</i> <i>nonce</i>)</code></h3>

Create boxing and unboxing procedures.

<h2>Symmetric Signatures</h2>

<h3>constant: <code>symmetric-sign-algorithm</code></h3>

The name of the symmetric signature algorithm.

<h3>constant: <code>symmetric-sign-keybytes</code></h3>

Byte lengths of algorithm parameters.

<h3>procedure: <code>(make-symmetric-sign-key)</code></h3>
<h3>procedure: <code>(make-symmetric-sign-key <i>port</i>)</code></h3>

Generate a new key using entropy from the given port or from <tt>(current-entropy-port)</tt>.

<h3>procedure: <code>((symmetric-sign <i>k</i>) <i>data</i>)</code></h3>
<h3>procedure: <code>((symmetric-verify <i>k</i>) <i>data</i>)</code></h3>

Create signature and verification procedures.

<h2>Message Digests</h2>

<h3>constant: <code>hash-algorithm</code></h3>

The name of the message digest algorithm.

<h3>procedure: <code>(hash <i>data</i>)</code></h3>

Compute the message digest of binary data.

Z a9204339826339acf8a1d75d7517f181