glenda.party
term% ls -F
term% pwd
$home/manuals/9front/2/ec
term% cat index.txt
EC(2)                         System Calls Manual                        EC(2)



NAME
       ecassign,  ecadd,  ecmul,  strtoec,  ecgen, ecverify, ecpubverify, ecd‐
       sasign, ecdsaverify - elliptic curve cryptography

SYNOPSIS
       #include <u.h>
       #include <libc.h>
       #include <mp.h>
       #include <libsec.h>

       void ecassign(ECdomain *dom, ECpoint *old, ECpoint *new);

       void ecadd(ECdomain *dom, ECpoint *a, ECpoint *b, ECpoint *s);

       void ecmul(ECdomain *dom, ECpoint *a, mpint *k, ECpoint *s);

       ECpoint*  strtoec(ECdomain *dom, char *s, char **rptr, ECpoint *p);

       ECpriv*   ecgen(ECdomain *dom, ECpriv *p);

       int  ecverify(ECdomain *dom, ECpoint *p);

       int  ecpubverify(ECdomain *dom, ECpub *p);

       void ecdsasign(ECdomain *dom, ECpriv *priv, uchar *dig, int dlen, mpint
       *r, mpint *s);

       int  ecdsaverify(ECdomain *dom, ECpub *pub, uchar *dig, int dlen, mpint
       *r, mpint *s);

DESCRIPTION
       These functions implement elliptic  curve  cryptography.   An  elliptic
       curve together with cryptographic parameters are specified using an EC‐
       domain struct.  Points on the curve are represented by ECpoint structs.

       ecassign, ecadd and ecmul are analogous to their counterparts in mp(2).

       strtoec converts a hex string representing an octet string as specified
       in  Standards  for Efficient Cryptography (SEC) 1 to an ECpoint struct.
       Both uncompressed and compressed formats are supported.  If rptr is not
       nil,  it  is used to return the position in the string where the parser
       stopped.  If p is nil space is allocated automatically, else the  given
       struct is used.

       ecverify and ecpubverify verify that the given point or public key, re‐
       spectively, is valid.

       ecgen generates a keypair and returns a pointer to it.   If  p  is  nil
       space is allocated automatically, else the given struct is used.

       ecdsasign  and  ecdsaverify create or verify, respectively, a signature
       using the ECDSA scheme specified in SEC 1.  It is absolutely vital that
       dig  is a cryptographic hash to the message.  ecdsasign writes the sig‐
       nature to r and s which are assumed to be allocated properly.

RETURN VALUE
       *verify functions return 1 for a positive result.  Functions  returning
       pointers may return nil in case of error (e.g.  failing malloc(2)).

SOURCE
       /sys/src/libsec/port/ecc.c

SEE ALSO
       Standards for Efficient Cryptography (SEC) 1: Elliptic Curve Cryptogra‐
       phy - Certicom Research, 2009

HISTORY
       This implementation of elliptic curve cryptography  first  appeared  in
       9front (June, 2012).



                                                                         EC(2)