derecalliance / cryptography

cryptography primitives (secret sharing, secure channel) for implementing the DeRec protocol
Apache License 2.0
5 stars 0 forks source link

ShamirInterfaces #11

Closed jorabin closed 1 month ago

jorabin commented 10 months ago

given the refactoring of storeshare.proto I think ShamirInterfaces spec is wrong . It should just provide for splitting a byte[] and recombining byte[]s the other parameters are not relevant?

Pls confirm @rsinha that this is actually what it implements at present?

this is actually what is needed, I think:

/**
 * Interface for sharing and recombining shares as byte arrays.
 */
public interface DeRecShareProvider {
    /**
     * Create shares from an array
     * @param bytesToShare the bytes to share
     * @param count the number of shares
     * @param threshold the recombination threshold
     * @return a list of count shares
     */
    List<byte[]> share (byte[] bytesToShare, int count, int threshold);

    /**
     * Recombine some shares  
     * @param shares the shares to combine
     * @return the combined shares
     */
    byte [] combine (List<byte[]> shares);
}
jorabin commented 8 months ago

Following agreement at 2024-01-12 meeting, this interface will move to api-java in a modified form adding the secretId and the version number for CommittedDeRecShare purposes. (see below). It needs to be removed from the cryptography repo and Java binding needs to be altered to match interface.

    /**
     * Some kind of error was encountered when recombining shares
     */
    class RecombinationException extends Exception {}

    /**
     * Not enough shares were provided to recombine
     */
    class ThresholdException extends RecombinationException {}

    /**
     * Create shares from an array of bytes
     * @param secretId the id of the secret
     * @param version the version number of the secret
     * @param bytesToShare the bytes of the secret and any additional metadata
     * @param count the number of shares to create
     * @param threshold the recombination threshold
     * @return a list of [count] shares
     */
    List<byte[]> share (byte[] secretId, int version, byte[] bytesToShare, int count, int threshold);

    /**
     * Recombine some shares
     * @param shares the shares to combine
     * @return the combined shares
     */
    byte [] combine (List<byte[]> shares) throws RecombinationException;
rsinha commented 5 months ago

Can we close this issue (and create a new one if appropriate)? jni/src/DerecCryptoInterface.java implements the discussed interface.