Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Delegation Builder #20

Open
wants to merge 5 commits into
base: v1.0-rc.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 1 addition & 24 deletions src/crypto/signature/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,6 @@ pub trait Envelope: Sized {
Ok(w)
}

/// Attempt to sign some payload with a given signer.
///
/// # Arguments
///
/// * `signer` - The signer to use to sign the payload.
/// * `payload` - The payload to sign.
///
/// # Errors
///
/// * [`SignError`] - the payload can't be encoded or the signature fails.
// FIXME ported
fn try_sign(
signer: &<Self::DID as Did>::Signer,
varsig_header: Self::VarsigHeader,
payload: Self::Payload,
) -> Result<Self, SignError>
where
Ipld: Encode<Self::Encoder>,
Named<Ipld>: From<Self::Payload>,
{
Self::try_sign_generic(signer, varsig_header, payload)
}

matheus23 marked this conversation as resolved.
Show resolved Hide resolved
/// Attempt to sign some payload with a given signer and specific codec.
///
/// # Arguments
Expand All @@ -126,7 +103,7 @@ pub trait Envelope: Sized {
///
/// # Example
///
fn try_sign_generic(
fn try_sign(
signer: &<Self::DID as Did>::Signer,
varsig_header: Self::VarsigHeader,
payload: Self::Payload,
Expand Down
8 changes: 4 additions & 4 deletions src/crypto/varsig/header/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ use libipld_core::codec::{Codec, Encode};
use signature::Verifier;
use thiserror::Error;

pub trait Header<Enc: Codec>: for<'a> TryFrom<&'a [u8]> + Into<Vec<u8>> {
pub trait Header<C: Codec>: for<'a> TryFrom<&'a [u8]> + Into<Vec<u8>> {
type Signature: signature::SignatureEncoding;
type Verifier: signature::Verifier<Self::Signature>;

fn codec(&self) -> &Enc;
fn codec(&self) -> &C;

fn encode_payload<T: Encode<Enc>, Buf: std::io::Write>(
fn encode_payload<T: Encode<C>, Buf: std::io::Write>(
&self,
payload: T,
buffer: &mut Buf,
) -> Result<(), libipld_core::error::Error> {
payload.encode(Self::codec(self).clone(), buffer)
}

fn try_verify<'a, T: Encode<Enc>>(
fn try_verify<'a, T: Encode<C>>(
&self,
verifier: &'a Self::Verifier,
signature: &'a Self::Signature,
Expand Down