module Hacl.Impl.P256.DH open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Lib.ByteSequence open Spec.DH open Spec.ECDSAP256.Definition inline_for_extraction noextract val ecp256dh_i: result:lbuffer uint8 (size 64) -> scalar:lbuffer uint8 (size 32) -> Stack bool (requires fun h -> live h result /\ live h scalar /\ disjoint result scalar) (ensures fun h0 r h1 -> let pointX, pointY, flag = ecp256_dh_i (as_seq h0 scalar) in modifies (loc result) h0 h1 /\ r == flag /\ as_seq h1 (gsub result (size 0) (size 32)) == pointX /\ as_seq h1 (gsub result (size 32) (size 32)) == pointY) inline_for_extraction noextract val ecp256dh_r: result:lbuffer uint8 (size 64) -> pubKey:lbuffer uint8 (size 64) -> scalar:lbuffer uint8 (size 32) -> Stack bool (requires fun h -> live h result /\ live h pubKey /\ live h scalar /\ disjoint result pubKey /\ disjoint result scalar) (ensures fun h0 r h1 -> let pubKeyX = gsub pubKey (size 0) (size 32) in let pubKeyY = gsub pubKey (size 32) (size 32) in let pointX, pointY, flag = ecp256_dh_r (as_seq h0 pubKeyX) (as_seq h0 pubKeyY) (as_seq h0 scalar) in r == flag /\ modifies (loc result) h0 h1 /\ as_seq h1 (gsub result (size 0) (size 32)) == pointX /\ as_seq h1 (gsub result (size 32) (size 32)) == pointY)