From fc30df740144b0cd1f9e79c92256d03e3fa184d0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 24 Nov 2020 23:48:54 -0800 Subject: [PATCH] hoon: adds new +mug (as +gum) --- pkg/arvo/sys/hoon.hoon | 17 +++++++++++ pkg/arvo/tests/sys/hoon/hashes.hoon | 44 +++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/pkg/arvo/sys/hoon.hoon b/pkg/arvo/sys/hoon.hoon index 30a82a510..8e091aada 100644 --- a/pkg/arvo/sys/hoon.hoon +++ b/pkg/arvo/sys/hoon.hoon @@ -1081,6 +1081,23 @@ =+ ham=(mix (rsh 0 31 haz) (end 0 31 haz)) ?.(=(0 ham) ham $(syd +(syd))) -- +++ gum + ~/ %gum + |= a=* + |^ ?@ a (mum 0xcafe.babe 0x7fff a) + =/ b (cat 5 $(a -.a) $(a +.a)) + (mum 0xdead.beef 0xfffe b) + :: + ++ mum + |= [syd=@uxF fal=@F key=@] + =/ wyd (met 3 key) + =| i=@ud + |- ^- @F + ?: =(8 i) fal + =/ haz=@F (muk syd wyd key) + =/ ham=@F (mix (rsh 0 31 haz) (end 0 31 haz)) + ?.(=(0 ham) ham $(i +(i), syd +(syd))) + -- :: :: :::: 2f: noun ordering :: :: :: diff --git a/pkg/arvo/tests/sys/hoon/hashes.hoon b/pkg/arvo/tests/sys/hoon/hashes.hoon index c9c8d9332..0a0e44b9c 100644 --- a/pkg/arvo/tests/sys/hoon/hashes.hoon +++ b/pkg/arvo/tests/sys/hoon/hashes.hoon @@ -53,6 +53,50 @@ !> 0x2ad3.9968 !> (mug [(dec (bex 128)) 1]) == +:: +++ test-gum + ;: weld + %+ expect-eq + !> 0x4d44.1035 + !> (gum 'Hello, world!') + :: + %+ expect-eq + !> 0x79ff.04e8 + !> (gum 0) + :: + %+ expect-eq + !> 0x715c.2a60 + !> (gum 1) + :: + %+ expect-eq + !> 0x64df.da5c + !> (gum (crip (reap 28 'x'))) + :: + %+ expect-eq + !> 0x192f.5588 + !> (gum [0 0]) + :: + %+ expect-eq + !> 0x6b32.ec46 + !> (gum [1 1]) + :: + %+ expect-eq + !> 0x2ef.fe10 + !> (gum [2 2]) + :: + %+ expect-eq + !> 0x3a81.1aec + !> (gum [1 2 3]) + :: + %+ expect-eq + !> 0x7ce.fb7f + !> (gum [0 (bex 32)]) + :: + %+ expect-eq + !> 0x2aa0.6bfc + !> (gum [(dec (bex 128)) 1]) + == +:: :: SHA tests :: For references see FIPS180-4 and related test vectors :: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf