Re: [TLS] PKIX drafts on EdDSA/Ed25519 and Curve25519/Curve448

Michael Hamburg <mike@shiftleft.org> Tue, 30 June 2015 19:00 UTC

Return-Path: <mike@shiftleft.org>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 92F731B2C7B for <tls@ietfa.amsl.com>; Tue, 30 Jun 2015 12:00:59 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 2.155
X-Spam-Level: **
X-Spam-Status: No, score=2.155 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FH_HOST_EQ_D_D_D_D=0.765, FH_HOST_EQ_D_D_D_DB=0.888, HELO_MISMATCH_ORG=0.611, HOST_MISMATCH_NET=0.311, J_CHICKENPOX_14=0.6, RDNS_DYNAMIC=0.982, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jkycUNvz8vch for <tls@ietfa.amsl.com>; Tue, 30 Jun 2015 12:00:58 -0700 (PDT)
Received: from aspartame.shiftleft.org (199-116-74-168-v301.PUBLIC.monkeybrains.net [199.116.74.168]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2E4221B37D8 for <tls@ietf.org>; Tue, 30 Jun 2015 12:00:45 -0700 (PDT)
Received: from [10.184.148.249] (unknown [209.36.6.242]) by aspartame.shiftleft.org (Postfix) with ESMTPSA id B07C93A9C5; Tue, 30 Jun 2015 11:57:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shiftleft.org; s=sldo; t=1435690630; bh=t6bCMya5Kg2MRMylozvoNDqGi8rwBoFALcHvjhnh+k8=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=RJ9hrs52TYoKV1I26ngO3hArfuHy8CCpGnu/wFq5Fl2WBclHchdQ4uYws6DPJWPi4 NRlSWW+i3t0x6fImKUrtiNwRB8OnalznFGYgdjTtNQfn1T3CnfsyNbWPvodFRUkU74 Ebv0UDV0tDLnNxaWbMAQx0vduoU4EJQ3GQnpuT6s=
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\))
From: Michael Hamburg <mike@shiftleft.org>
In-Reply-To: <20150630082022.GB6141@LK-Perkele-VII>
Date: Tue, 30 Jun 2015 12:00:44 -0700
Content-Transfer-Encoding: quoted-printable
Message-Id: <0F04C44E-8DFF-47EB-9717-90179BF4ABE1@shiftleft.org>
References: <87lhf29nr4.fsf@latte.josefsson.org> <20150630082022.GB6141@LK-Perkele-VII>
To: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
X-Mailer: Apple Mail (2.2102)
Archived-At: <http://mailarchive.ietf.org/arch/msg/tls/9RdUGMRkeRmAnTUIuVmoz0LbiM0>
Cc: Simon Josefsson <simon@josefsson.org>, tls@ietf.org
Subject: Re: [TLS] PKIX drafts on EdDSA/Ed25519 and Curve25519/Curve448
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tls/>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 30 Jun 2015 19:00:59 -0000

> On Jun 30, 2015, at 1:20 AM, Ilari Liusvaara <ilari.liusvaara@elisanet.fi> wrote:
> 
> On Tue, Jun 30, 2015 at 12:02:39AM +0200, Simon Josefsson wrote:
>> 
>> A couple of people suggested to define encodings for Curve25519/Curve448
>> (the CFRG curves) public keys.  I didn't see that this necessarily had
>> to be in the above document, so I put it in a separate document.  I'm
>> not entirely sure how useful this is, or if I may have completely
>> misunderstood what people had in mind. 
> 
> Well, EdDSA-like scheme (obtained by dropping constraints on curve
> and hash[1] and generation of a and seed[2])  would be:
> 
> (a and seed generated from secret)
> r = h(seed || M)
> R = rB
> A = aB
> s = (r + h(encode_p(R) || encode_p(A) || M) * a) mod l
> signature = encode_p(R) || encode_s(s)
> public key = encode_p(A)
> 
> (Multiply equation for s to get verification equation:
> sB = R + h(encode_p(R) || encode_p(A) || M) * A )
> 
> (One can obtain Ed25519 from this by substituting suitable a / seed
> generation, B and functions h, encode_p and encode_a.)
> 
> 
> And since encode_p(X) is inside hash, one must pin it down for the
> scheme to work (interoperate between signers and verifiers), along
> with the hash function h to use.
> 
> Edwards curves are always constant or quadric in x for in every
> term of curve equation. Which means that x can be compressed to
> a single LSB bit (Ed25519 paper is somewhat unclearly worded IMO,
> but this is what it does for prime curves[3][4]).
> 
> There's also encode_s(x), but it is straightforward (can just use
> little-endian base-256 integer encoding.
> 
> 
> [1] Enabling it to work on curves other than very few ones, especially
> with standard-issue hashes.
> 
> [2] Since hash function length is insufficient for the method used in
> Ed25519 without using exotic hashes.
> 
> [3] There are other possibilities, but LSB bit (even/odd) seems to be
> the easiest to extract and to compare.
> 
> [4] For Ed448 there is also encoding from Ed448-Goldilocks, which is
> 56 bytes (448 bits) instead of 57 bytes (449 bits). But it is fair
> bit more complicated (slow) than straightforward point compression.
> 
> 
> -Ilari

To clarify, the encoding in Ed448-Goldilocks, and its successor “decaf”,
are more complicated than straightforward point compression but not
significantly slower.

There is also the alternative of (low bit of x is 0) ? y : -y, with the identity
(0,1) mapped arbitrarily to 1.

As for hash functions, the hash function used to produce the challenge
doesn’t have to be uniform.  It doesn’t even have to output a number as
big as the curve — half as big is good enough — but most schemes use
the full length for extra conservatism.  Also, if the curve order is close to
a power of 2 (i.e. 2^bleh +- O(2^(bleh/2))), then a hash the same length
as the order is good enough for choosing the seed.  You only need a
longer seed if the curve is not close enough to a power of 2, eg P256 or
Brainpool.  But it is nice to be able to choose the same hash function for
every curve of the same size.

Cheers,
— Mike