unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: "Jelle Licht" <jlicht@fsfe.org>, "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: Using G-Expressions for public keys (substitutes and possibly more)
Date: Sun, 21 Nov 2021 09:28:44 +0100	[thread overview]
Message-ID: <d8b092460dd14179fc200a18f5dfb7417fa6dff5.camel@gmail.com> (raw)
In-Reply-To: <86k0h2jris.fsf@fsfe.org>

Hi,

Am Sonntag, den 21.11.2021, 01:12 +0100 schrieb Jelle Licht:
> What about something such as the following?
> 
> --8<---------------cut here---------------start------------->8---
> (use-modules (gcrypt base16)
>              (gcrypt pk-crypto))
> 
> (define-record-type <canonical-sexp-wrapper>
>   (canonical-sexp-wrapper name sexp)
>   canonical-sexp-wrapper?
>   (name canonical-sexp-wrapper-name)
>   (sexp canonical-sexp-wrapper-sexp))
> 
> (define-gexp-compiler (canonical-sexp-wrapper-compiler
>                        (wrapper <canonical-sexp-wrapper>) system
> target)
>   (match wrapper
>     (($ <canonical-sexp-wrapper> name sexp)
>      (text-file name (canonical-sexp->string
>                       (sexp->canonical-sexp sexp)) '()))))
> --8<---------------cut here---------------end--------------->8---
> 
> This would still leave constructing your s-expression as an exercise
> to the reader, which is definitely not amazing. In this specific
> instance, I had to look at the output of canonical-sexp->sexp, which
> is of course whatever the opposite of discoverable and good UX :).
Apart from the name "-wrapper" instead of "-file", I think this would
be acceptable.  I think we ought to handle two cases here, though: one
with sexp being a sexp, and one with it being a canonical sexp.

> For the Ed25519 key:
> --8<---------------cut here---------------start------------->8---
> (define my-public-key
>   (canonical-sexp-wrapper
>    "my-key.pub"
>    `(public-key
>      (ecc
>       (curve Ed25519)
>       (q ,(base16-string->bytevector
>            (string-downcase
>             "C9F307AE...")))))))
> --8<---------------cut here---------------end--------------->8---
> 
> To improve on this, is one sexp-based-gexp-compiler + N helper
> functions to construct the most-used value types a direction worth
> exploring?
I think we would probably want to improve on this end in the guile-
gcrypt module, i.e. have a public-key "constructor" that returns a
canonical-sexp and so on.  WDYT?



  reply	other threads:[~2021-11-21  8:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-17 12:47 Using G-Expressions for public keys (substitutes and possibly more) Liliana Marie Prikler
2021-10-21 20:13 ` Ludovic Courtès
2021-10-22  4:47   ` Liliana Marie Prikler
2021-11-21  0:12     ` Jelle Licht
2021-11-21  8:28       ` Liliana Marie Prikler [this message]
2021-11-22 13:27         ` Ludovic Courtès
2021-11-22 14:32           ` Jelle Licht
2021-11-22 19:35           ` Liliana Marie Prikler
2021-11-23 17:14             ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d8b092460dd14179fc200a18f5dfb7417fa6dff5.camel@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=jlicht@fsfe.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).