Re: [Cfrg] Adoption request: draft-hdevalence-cfrg-ristretto

"Riad S. Wahby" <rsw@jfet.org> Thu, 25 July 2019 00:46 UTC

Return-Path: <rswatjfet.org@gmail.com>
X-Original-To: cfrg@ietfa.amsl.com
Delivered-To: cfrg@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 58258120625 for <cfrg@ietfa.amsl.com>; Wed, 24 Jul 2019 17:46:38 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 3.442
X-Spam-Level: ***
X-Spam-Status: No, score=3.442 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.091, FREEMAIL_FROM=0.001, GB_SUMOF=5, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=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 fDCEh6lDKVMf for <cfrg@ietfa.amsl.com>; Wed, 24 Jul 2019 17:46:36 -0700 (PDT)
Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6A54912068E for <cfrg@irtf.org>; Wed, 24 Jul 2019 17:46:36 -0700 (PDT)
Received: by mail-pg1-f180.google.com with SMTP id i18so22057141pgl.11 for <cfrg@irtf.org>; Wed, 24 Jul 2019 17:46:36 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mxcIwKM5HV+G7snTBck4K1m6Akx7nVl8noimUUHE7/w=; b=nBCuowl1WttFlaMlVj3RP0c5UWBAnqa39yCG8u1gx3vM93L2COLI1g+8phqzh4xgFu 0Lc8JC+ujjrIgmITnNAv/DUAzQOUERu+vEhHn1/AaajTsCOzP8HfSCa+enWneTDF8Qub fC7VUHqpIVckbPHxngUOlznka+OZpisPxN/eLQCdysvE1W7IjvclwdQz4ApQQ+vsHdcd Zbj9lNWKDS97sZB1gWsUEap7cxb8iEfdJ4nohd6TK/fU7esCbc5ZOrGTqi8DAwHV4kx1 oYtJLscSiSUEOzVqgJIDm+rS5GIB2u+9m3UiKnba3G0j+Uqjjs1q4CQrHNlPY6yF9MDf 7uvQ==
X-Gm-Message-State: APjAAAUjbyS+IhnFuAUv5z+t4TysXv2OMaYGWGG/n0JFqU8h9Iaq2zMQ Sfgy3WWlp+a4/hl0bMk9Fu8=
X-Google-Smtp-Source: APXvYqzFWONsb87YSgVsLowz0eyfO0qrHOSiGXSPnHHB0eYjPtHaw/lEX4h46D664mE/gfmrNTBQIg==
X-Received: by 2002:a65:4044:: with SMTP id h4mr83955794pgp.164.1564015595798; Wed, 24 Jul 2019 17:46:35 -0700 (PDT)
Received: from localhost (positron.stanford.edu. [171.67.76.114]) by smtp.gmail.com with ESMTPSA id n17sm48380654pfq.182.2019.07.24.17.46.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jul 2019 17:46:34 -0700 (PDT)
Date: Wed, 24 Jul 2019 17:46:33 -0700
From: "Riad S. Wahby" <rsw@jfet.org>
To: Jack Grigg <ietf@jackgrigg.com>
Cc: Jeff Burdges <jeff@web3.foundation>, cfrg@irtf.org, draft-hdevalence-cfrg-ristretto@ietf.org
Message-ID: <20190725004633.l5k7toldcgy7uthb@positron.jfet.org>
References: <a505c99b-32a9-447a-9c69-a8efe3ed1b70@www.fastmail.com> <0370cd6b-adf3-4be2-9ab4-79693b9dc096@www.fastmail.com> <B7F73174-29F0-4B83-8AC0-A7D42D372D4A@inf.ethz.ch> <075d43b1-e123-42a9-ccd9-64fe45306f8b@web3.foundation> <20190724212030.ddcswlg5uxm3muzo@positron.jfet.org> <CAPC=aNVCV2cn62rhQsu+RsJsdjt2Dqqw_rqooLsuc8J5v9s3kQ@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAPC=aNVCV2cn62rhQsu+RsJsdjt2Dqqw_rqooLsuc8J5v9s3kQ@mail.gmail.com>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/Y0hoIje8blDrzZk-IVOkQL4JWP8>
Subject: Re: [Cfrg] Adoption request: draft-hdevalence-cfrg-ristretto
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Crypto Forum Research Group <cfrg.irtf.org>
List-Unsubscribe: <https://www.irtf.org/mailman/options/cfrg>, <mailto:cfrg-request@irtf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cfrg/>
List-Post: <mailto:cfrg@irtf.org>
List-Help: <mailto:cfrg-request@irtf.org?subject=help>
List-Subscribe: <https://www.irtf.org/mailman/listinfo/cfrg>, <mailto:cfrg-request@irtf.org?subject=subscribe>
X-List-Received-Date: Thu, 25 Jul 2019 00:46:45 -0000

Hi Jack,

Thanks very much for the answers. Can you please help me understand
a bit more what's going on?

(At the risk of protesting too much, I want to be clear that the
concerns below are sincere: I really cannot square the claims in
this thread with the content of the document or my understanding of
Decaf/Ristretto. As background, I've read the Decaf paper carefully
and implemented it fully. So I don't think it is much of a stretch
to suppose that if I can't parse what's going on in this document,
there are plenty of others out there who won't be able to, either.)

Jack Grigg <ietf@jackgrigg.com> wrote:
> The ability for ristretto255 implementations to interoperate, despite using
> different internal representations, is contingent on implementors following
> the normative requirement that the internal representations are not
> exposed, or operated on except via the Ristretto APIs. This precludes any
> mapping from ristretto255 elements to edwards25519 points.

Sorry, I don't understand. Per the rest of your email, DECODE as
specified in Section 3 is exactly such a mapping. So how am I to
interpret what you've said above?

Concretely: let's say I want to output the sum of two ristretto255
points, P1 and P2. To do that, I think I need to do something like this
(all functions as specified in Section 3):

    P1_decoded = DECODE(P1)
    P2_decoded = DECODE(P2)
    Q_decoded = P1_decoded (+) P2_decoded
    Q = ENCODE(Q_decoded)

The problem is, the document as currently written does not tell me
how to implement the (+) operator on the third line above. It implies
that such an operator exists (in Section 3.3), but as far as I can
tell it does not tell me what it is.

Is it edwards25519 point addition? If so, then I just don't see how
it can be true that the "internal representation" in Section 3 is
not an edwards25519 point. (Sure, equality testing is different.
What else is different? What is the same?)

> Put another way: if a mapping from ristretto255 elements to edwards25519
> points existed, any higher-level protocol that leveraged this mapping would
> only work with ristretto255 implementations specifically constructed over
> edwards25519, breaking interoperability across ristretto255 implementations.

It's not obvious (to me!) from the draft, the Decaf paper, etc.
why this should be true. So I think it will be important to spell it
out somewhere (or maybe I just need to read Decaf more carefully---in
which case, apologies).

Here's something I might stupidly decide to do:

    P_decoded = DECODE(P)
    P_montgomery = Edwards_To_Montgomery(P_decoded)
    Q_montgomery = my_scalar (*) P_montgomery
    Q_decoded = Montgomery_To_Edwards(Q_montgomery)
    Q = ENCODE(Q_decoded)

Here, P_montgomery and Q_montgomery are points on curve25519,
Edwards_To_Montgomery and Montgomery_To_Edwards correspond to
the birational map of RFC7748, Section 4.1, and (*) is scalar
multiplication on the Montgomery curve.

Meanwhile, a better implementor might instead do

    P_decoded = DECODE(P)
    R_decoded = my_scalar (*) P_decoded
    R = ENCODE(R_decoded)

Here, (*) is scalar multiplication on edwards25519.

So, finally, the question: is the claim that R != Q? I don't see
how that can be true given the birational equivalence of curve25519
and edwards25519.

Alternatively, if R == Q, then what's the problem with converting
back and forth between Edwards and Montgomery points, and why am
I not correct in thinking of P_decoded as an edwards25519 point?
Is it just that certain operations (equality checking, ...???)
don't work the same as a "real" edwards25519 point?

> It is an explicit design decision to define the Ristretto API solely in
> terms of the four provided operations:

OK, but this can't actually be true, because there are other operations
alluded to (but not defined) in the document, and without those
operations (point addition, point inversion, scalar multiplication)
ristretto255 doesn't actually let me do anything.

> I agree! This is what the current draft aims to do, by allowing
> implementors to use whatever internal representation they choose.
> Specifically, the document intends to specify the normative behavior of the
> group and the API, while providing informationally the details of one
> possible implementation, the one based on edwards25519. If there are ways
> we can make this more clear, please do send suggestions.

I'm hoping to get to the point where I can make such suggestions,
but first I have to actually understand what's going on!

Here's my current best guess:

ENCODE and DECODE convert ristretto255 points into some internal
representation. For the algorithms in Section 3, that internal
representation is edwards25519, except that equality testing is
different (specifically, it must use EQUALS) and maybe some other
things are different (but I don't know what).

Operations are the same as for edwards25519, but the only ones that
are allowed are addition, inversion, and multiplication.

Implementors can maybe use a different internal representation. There
is no obvious way to do this given the information in the document.
In particular, there is no group isomorphic to Curve25519 with order l,
because Curve25519 has order 8 * l.

> > If my interpretation is correct, then I suggest the authors provide
> > a mapping that implementations MAY use, as a way of assisting
> > implementors in getting things right. This is probably as simple as
> > citing the birational map between edwards25519 and curve25519 from
> > Section 4.1 of RFC7748, and explaining how to use this map in concert
> > with the Ristretto functions.
> 
> Per above, the way to ensure implementors get things right is to prohibit
> such a mapping (which would necessarily be breaking the API provided by the
> Ristretto functions, rather than being a mapping operating behind them).

Does the document prohibit such a mapping? Is this the intent
of Section 3.3? What would go wrong if I did this, assuming that
after mapping (say) an edwards25519 point to a curve25519 point, I
continued to observe the restriction that only addition, inversion,
and multiplication are allowed?

(I think this is the same as my question about Q and R, above.)

> This is a salient point. We in fact mean edwards25519 throughout the text,
> but almost every implementation of edwards25519 that isn't built into an
> Ed25519 implementation is provided in a Curve25519 library, and I figure
> the latter is more familiar to readers (even RFC7748 only contains a single
> occurrence of "edwards25519"). I personally would be happy to replace all
> occurrences of "Curve25519" with "edwards25519", but I would like to hear
> from the other authors on this point.

On the other hand, RFC7748 contains 12 occurrences of "curve25519"
(17 if you turn off case sensitivity) and every one of those refers
to the Montgomery curve, not the Edwards curve. So as far as I can
tell there is no way for a reader to understand this document as
currently written other than to guess that when you say "Curve25519"
you actually mean "edwards25519", not "curve25519".

> If all occurrences of "Curve25519" were replaced with "edwards25519", would
> this be clearer? For this particular example, the intention is that DECODE
> takes a 32-byte string and returns either an error, or a ristretto255
> element that is internally represented as a point (X : Y : Z : T) on
> edwards25519.

Sure, that would help. But then it's impossible to understand the
claim from two emails ago that there's no mapping from ristretto255
to edwards25519, because ENCODE and DECODE appear to be exactly
such mappings!

Sure, it's non-normative, I get that, no worries. But how is it
possible for me to understand the claim that mapping to edwards25519
would break compatibility when the document demonstrates exactly such a
mapping and claims that all other mappings must be compatible with it?

Thank you preemptively for putting up with my confusion,

-=rsw