Giter Site home page Giter Site logo

Comments (3)

oconnor663 avatar oconnor663 commented on August 23, 2024

Another real world hazard is that you can't just change the associated data parameters over time. If you want to add a third parameter (let's say the filesystem type), you need to change the context string in step 1. Otherwise the key you were using for [application stuff] before is now an intermediate subkey, which is no bueno.

If we wanted a scheme that was robust to this, we could imagine some sort of "finalization" step, that distinguishes between intermediate subkeys and output subkeys. But is that really necessary? I feel like encouraging people to reuse the same context string would be a bad precedent.

from blake3.

Luro02 avatar Luro02 commented on August 23, 2024

What we don't want to do is skip steps entirely

You could use the rust type system for this, for example

pub struct Stage2 {
}

impl Stage2 {
    pub(crate) fn new() -> Self {
        Self {}
    }

    pub fn start_hash(data: &[u8]) {}
}

pub fn init_key(_: &str) -> Stage2 {
    // do something necessary
    Stage2::new()
}

This would make it impossible to call start_hash without calling init_key, so there is no possible way to skip this step.

Alternatively you could also wrap the data in a new type

struct Key(Vec<u8>);

which could then be passed to a function as an argument.

from blake3.

oconnor663 avatar oconnor663 commented on August 23, 2024

Agreed, providing a secure Rust API for key derivation with associated data wouldn't be too hard. But I'm thinking more about providing advice for protocol designers. Or maybe for coders using some other implementation of BLAKE3, in some other language. (Maybe even folks who aren't using BLAKE3.) I'm hoping to define some sort of Right Way to Do It in the abstract.

from blake3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.