Skip to content

x/crypto/{blake2b,blake2s}: implement encoding.BinaryMarshaler and encoding.BinaryUnmarshaler #24548

Closed
@ValarDragon

Description

@ValarDragon

It is often useful to be able to copy the internal state for blake2b, such as if you want to compute Blake2b(msg || tag1) and Blake2b(msg || tag2), and you want to avoid double-computing what results from updating msg.

I've added a clone method to do this here. This is an improvement that can't be made in applications using the library, since the digest struct isn't exported.

Since the publicly visible interface for digest is hash.Hash, I made the method for cloning func Clone(h hash.Hash) (*digest, error) instead of func (d *digest) Clone (*digest).

This could alternatively be added as a method that everything which implements the hash.Hash interface must implement, since there have been requests for this before. (Link 1, Link 2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions