Urbit Docs
  • What is Urbit?
  • Get on Urbit
  • Build on Urbit
    • Contents
    • Environment Setup
    • Hoon School
      • 1. Hoon Syntax
      • 2. Azimuth (Urbit ID)
      • 3. Gates (Functions)
      • 4. Molds (Types)
      • 5. Cores
      • 6. Trees and Addressing
      • 7. Libraries
      • 8. Testing Code
      • 9. Text Processing I
      • 10. Cores and Doors
      • 11. Data Structures
      • 12. Type Checking
      • 13. Conditional Logic
      • 14. Subject-Oriented Programming
      • 15. Text Processing II
      • 16. Functional Programming
      • 17. Text Processing III
      • 18. Generic and Variant Cores
      • 19. Mathematics
    • App School I
      • 1. Arvo
      • 2. The Agent Core
      • 3. Imports and Aliases
      • 4. Lifecycle
      • 5. Cards
      • 6. Pokes
      • 7. Structures and Marks
      • 8. Subscriptions
      • 9. Vanes
      • 10. Scries
      • 11. Failure
      • 12. Next Steps
      • Appendix: Types
    • App School II (Full-Stack)
      • 1. Types
      • 2. Agent
      • 3. JSON
      • 4. Marks
      • 5. Eyre
      • 6. React app setup
      • 7. React app logic
      • 8. Desk and glob
      • 9. Summary
    • Core Academy
      • 1. Evaluating Nock
      • 2. Building Hoon
      • 3. The Core Stack
      • 4. Arvo I: The Main Sequence
      • 5. Arvo II: The Boot Sequence
      • 6. Vere I: u3 and the Serf
      • 7. Vere II: The Loom
      • 8. Vanes I: Behn, Dill, Kahn, Lick
      • 9. Vanes II: Ames
      • 10. Vanes III: Eyre, Iris
      • 11. Vanes IV: Clay
      • 12. Vanes V: Gall and Userspace
      • 13. Vanes VI: Khan, Lick
      • 14. Vanes VII: Jael, Azimuth
    • Runtime
      • U3
      • Conn.c Guide
      • How to Write a Jet
      • API Overview by Prefix
      • C in Urbit
      • Cryptography
      • Land of Nouns
    • Tools
      • Useful Links
      • JS Libraries
        • HTTP API
      • Docs App
        • File Format
        • Index File
        • Suggested Structure
    • Userspace
      • Command-Line App Tutorial
      • Remote Scry
      • Unit Tests
      • Software Distribution
        • Software Distribution Guide
        • Docket File
        • Glob
      • Examples
        • Building a CLI App
        • Debugging Wrapper
        • Host a Website
        • Serving a JS Game
        • Ship Monitoring
        • Styled Text
  • Urbit ID
    • What is Urbit ID?
    • Azimuth Data Flow
    • Life and Rift
    • Urbit HD Wallet
    • Advanced Azimuth Tools
    • Custom Roller Tutorial
    • Azimuth.eth Reference
    • Ecliptic.eth Reference
    • Layer 2
      • L2 Actions
      • L2 Rollers
      • L2 Roller HTTP RPC-API
      • L2 Transaction Format
  • Urbit OS
    • What is Urbit OS?
    • Base
      • Hood
      • Threads
        • Basics Tutorial
          • Bind
          • Fundamentals
          • Input
          • Output
          • Summary
        • HTTP API Guide
        • Spider API Reference
        • Strandio Reference
        • Examples
          • Child Thread
          • Fetch JSON
          • Gall
            • Poke Thread
            • Start Thread
            • Stop Thread
            • Take Facts
            • Take Result
          • Main-loop
          • Poke Agent
          • Scry
          • Take Fact
    • Kernel
      • Arvo
        • Cryptography
        • Move Trace
        • Scries
        • Subscriptions
      • Ames
        • Ames API Reference
        • Ames Cryptography
        • Ames Data Types
        • Ames Scry Reference
      • Behn
        • Behn API Reference
        • Behn Examples
        • Behn Scry Reference
      • Clay
        • Clay API Reference
        • Clay Architecture
        • Clay Data Types
        • Clay Examples
        • Clay Scry Reference
        • Filesystem Hierarchy
        • Marks
          • Mark Examples
          • Using Marks
          • Writing Marks
        • Using Clay
      • Dill
        • Dill API Reference
        • Dill Data Types
        • Dill Scry Reference
      • Eyre
        • EAuth
        • Eyre Data Types
        • Eyre External API
        • Eyre Internal API
        • Eyre Scry Reference
        • Low-Level Eyre Guide
        • Noun channels
      • Gall
        • Gall API Reference
        • Gall Data Types
        • Gall Scry Reference
      • Iris
        • Iris API Reference
        • Iris Data Types
        • Iris Example
      • Jael
        • Jael API Reference
        • Jael Data Types
        • Jael Examples
        • Jael Scry Reference
      • Khan
        • Khan API Reference
        • Khan Data Types
        • Khan Example
      • Lick
        • Lick API Reference
        • Lick Guide
        • Lick Examples
        • Lick Scry Reference
  • Hoon
    • Why Hoon?
    • Advanced Types
    • Arvo
    • Auras
    • Basic Types
    • Cheat Sheet
    • Cryptography
    • Examples
      • ABC Blocks
      • Competitive Programming
      • Emirp
      • Gleichniszahlenreihe
      • Islands
      • Luhn Number
      • Minimum Path Sum
      • Phone Letters
      • Restore IP
      • Rhonda Numbers
      • Roman Numerals
      • Solitaire Cipher
      • Water Towers
    • Generators
    • Hoon Errors
    • Hoon Style Guide
    • Implementing an Aura
    • Irregular forms
    • JSON
    • Limbs and wings
      • Limbs
      • Wings
    • Mips (Maps of Maps)
    • Parsing Text
    • Runes
      • | bar · Cores
      • $ buc · Structures
      • % cen · Calls
      • : col · Cells
      • . dot · Nock
      • / fas · Imports
      • ^ ket · Casts
      • + lus · Arms
      • ; mic · Make
      • ~ sig · Hints
      • = tis · Subject
      • ? wut · Conditionals
      • ! zap · Wild
      • Constants (Atoms and Strings)
      • --, == · Terminators
    • Sail (HTML)
    • Serialization
    • Sets
    • Standard Library
      • 1a: Basic Arithmetic
      • 1b: Tree Addressing
      • 1c: Molds and Mold-Builders
      • 2a: Unit Logic
      • 2b: List Logic
      • 2c: Bit Arithmetic
      • 2d: Bit Logic
      • 2e: Insecure Hashing
      • 2f: Noun Ordering
      • 2g: Unsigned Powers
      • 2h: Set Logic
      • 2i: Map Logic
      • 2j: Jar and Jug Logic
      • 2k: Queue Logic
      • 2l: Container from Container
      • 2m: Container from Noun
      • 2n: Functional Hacks
      • 2o: Normalizing Containers
      • 2p: Serialization
      • 2q: Molds and Mold-Builders
      • 3a: Modular and Signed Ints
      • 3b: Floating Point
      • 3c: Urbit Time
      • 3d: SHA Hash Family
      • 3e: AES encryption (Removed)
      • 3f: Scrambling
      • 3g: Molds and Mold-Builders
      • 4a: Exotic Bases
      • 4b: Text Processing
      • 4c: Tank Printer
      • 4d: Parsing (Tracing)
      • 4e: Parsing (Combinators)
      • 4f: Parsing (Rule-Builders)
      • 4g: Parsing (Outside Caller)
      • 4h: Parsing (ASCII Glyphs)
      • 4i: Parsing (Useful Idioms)
      • 4j: Parsing (Bases and Base Digits)
      • 4k: Atom Printing
      • 4l: Atom Parsing
      • 4m: Formatting Functions
      • 4n: Virtualization
      • 4o: Molds
      • 5a: Compiler Utilities
      • 5b: Macro Expansion
      • 5c: Compiler Backend & Prettyprinter
      • 5d: Parser
      • 5e: Molds and mold builders
      • 5f: Profiling support
    • Strings
    • The Engine Pattern
    • Udon (Markdown-esque)
    • Vases
    • Zuse
      • 2d(1-5): To JSON, Wains
      • 2d(6): From JSON
      • 2d(7): From JSON (unit)
      • 2e(2-3): Print & Parse JSON
      • 2m: Ordered Maps
  • Nock
    • What is Nock?
    • Decrement
    • Definition
    • Fast Hints and Jets
    • Implementations
    • Specification
  • User Manual
    • Contents
    • Running Urbit
      • Cloud Hosting
      • Home Servers
      • Runtime Reference
      • Self-hosting S3 Storage with MinIO
    • Urbit ID
      • Bridge Troubleshooting
      • Creating an Invite Pool
      • Get an Urbit ID
      • Guide to Factory Resets
      • HD Wallet (Master Ticket)
      • Layer 2 for planets
      • Layer 2 for stars
      • Proxies
      • Using Bridge
    • Urbit OS
      • Basics
      • Configuring S3 Storage
      • Dojo Tools
      • Filesystem
      • Shell
      • Ship Troubleshooting
      • Star and Galaxy Operations
      • Updates
Powered by GitBook

GitHub

  • Urbit ID
  • Urbit OS
  • Runtime

Resources

  • YouTube
  • Whitepaper
  • Awesome Urbit

Contact

  • X
  • Email
  • Gather
On this page
  • Summary
  • +crub:crypto
  • +seal:as
  • +sign:as
  • +sure:as
  • +tear:as
  • +de
  • +dy
  • +en
  • +fig:ex
  • +pac:ex
  • +pub:ex
  • +sec:ex
  • +pit:nu
  • +nol:nu
  • +com:nu
  • +ed:crypto
  • +aes:crypto
Edit on GitHub
  1. Hoon

Cryptography

This is a summary of the cryptography functions found in sys/zuse.hoon, Arvo's standard library. This page currently only documents cryptographic functions directly utilized by Ames. zuse also contains cryptographic functions relevant to Ethereum such as the +keccak:crypto core, but they are currently undocumented.

Documentation for Insecure Hashing and the SHA Hash Family is found in the Hoon standard library reference.

Summary

zuse contains several cryptosuites. The ones utilized by Ames are +ed:crypto, +aes:crypto, and +crub:crypto, with the latter being the only one which is implemented as an +acru:ames-shaped core.

+crub:crypto

+crub:crypto implements an +acru:ames core that implements Suite B Cryptography.

It utilizes AES symmetric key encryption and decryption from +aes:crypto implemented using the Diffie-Hellman key exchange protocol, elliptic curve digital signature algorithm (ECDSA) signing and verification with +ed:crypto, and generates public/private key pairs using elliptic curve cryptography with +ed:crypto.

A +crub:crypto core's payload contains public encryption and authentication keys and optional secret encryption and authentication keys.

  ++  crub  !:
    ^-  acru
    =|  [pub=[cry=@ sgn=@] sek=(unit [cry=@ sgn=@])]
    |%
    ...

+crub cores (because they follow the +acru interface) are typically created using one of the constructors in +nu:crub.

+seal:as

      ++  seal                                          ::
        |=  [bpk=pass msg=@]
        ...

Forms a symmetric key using Diffie-Hellman key exchange with the secret key stored at sgn.u.sek and a public key bpk. Then +signs msg, encrypts the signed message using +en:siva:aes with the symmetric key, and then +jams it.

Crashes if sek is null.

+sign:as

      ++  sign                                          ::
        |=  msg=@
        ...

Signs message msg=@ using the secret authentication key sgn.u.sek, then forms a cell [signed-message msg] and +jams it.

Crashes if sek is null.

+sure:as

      ++  sure                                          ::
        |=  txt=@
        ...

+cues txt to get a signature sig=@ and message msg=@. Verifies that sig was msg signed using the secret key associated to the public key stored at sgn.pub. Returns (unit msg) if so, null otherwise.

+tear:as

      ++  tear                                          ::
        |=  [bpk=pass txt=@]
        ...

Forms a secret symmetric key using Diffie-Hellman key exchange using the secret key cry.u.sek and encryption key part of the public key bpk (which here is a concatenation of both the encryption and authentication public keys). +cues txt and decrypts it using +de:siva:aes with the symmetric key. If decryption is successful, verifies the decrypted message using authentication key part of bpk, and returns it if so. Returns null otherwise.

Crashes if sek is null.

+de

    ++  de                                              ::  decrypt
      |=  [key=@J txt=@]
      ...

+cues txt then decrypts with the symmetric key key using +de:sivc:aes. Returns null in case of failure.

+dy

    ++  dy                                              ::  need decrypt
      |=  [key=@J cph=@]
      ...

Same as +dy, but crashes in case of failure.

+en

    ++  en                                              ::  encrypt
      |=  [key=@J msg=@]

Encrypts msg with the symmetric key key using en:sivc:aes, then +jams it.

+fig:ex

Returns the fingerprint (SHA-256) of +pub:ex.

+pac:ex

Returns the fingerprint (SHA-256) of +sec:ex. Crashes if sek is null.

+pub:ex

Returns the concatenation of sgn.pub and cry.pub.

+sec:ex

Returns the concatenation of sgn.u.sek and cry.u.sek.

+pit:nu

      ++  pit                                           ::  create keypair
        |=  [w=@ seed=@]
        ...

Creates a +crub core with encryption and authentication public/private keypairs generated from a bitwidth w and seed. The private keys are generated with SHA-512, while +puck:ed:crypto is used to derive the public keys from the private keys.

This is how one typically generates a brand new +crub core for signing and encrypting your own messages.

+nol:nu

      ++  nol                                           ::  activate secret
        |=  a=ring
        ...

Takes in a ring from a +sec:ex:crub and generates a new +crub core with sek taken from +sec:ex and pub generated with +puck:ed:crypto. Crashes if +sec:ex is not a +crub secret key.

+com:nu

      ++  com                                           ::  activate public
        |=  a=pass
        ...

Takes in a pass from a +pub:ex:crub and generates a new +crub core with pub taken from +pub:ex and null sek.

+ed:crypto

This core contains cryptographic primitives and helper functions for elliptic curve cryptography with Curve25519.

+ed:crypto is primarily used to generate public/private keypairs from a seed for use with elliptic curve Diffie-Hellman key agreements as well as Elliptic Curve Digital Signature Algorithm. These functionalities are ultimately utilized by +crub:crypto, the only cryptosuite which Ames makes use of.

Most gates in +ed:crypto are jetted, meaning that an external reference library is utilized whenever these functions are called, rather than running in Nock natively. See the Vere documentation for more information about the library utilized by jets.

+aes:crypto

This core contains cryptographic primitives and helper functions for AES symmetric key encryption and decryption. As is the case with ed:crypto, these functionalities are utilized by +crub:crypto, and most gates are jetted. See also the Vere documentation on AES SIV for more information about the library utilized by jets.

This core contains several doors, each one used for a different variation of AES according to key size and mode. The only ones currently in use are +siva:aes:crypto and +sivc:aes:crypto, which are 128-bit and 256-bit modes of AES-SIV respectively.

PreviousCheat SheetNextExamples

Last updated 1 day ago