Permalink
Browse files

Calypso is ported.

  • Loading branch information...
jeffallen committed Sep 13, 2018
1 parent 25499d6 commit c9511e2a9da9fae70544432a786208d567cfc11e
File renamed without changes.
View
@@ -9,13 +9,13 @@ Calypso is the implementation of the upcoming "Calypso - Auditable Sharing of
Private Data over Blockchains". The paper can be found
[here](https://eprint.iacr.org/2018/209).
In short, Calypso allows to store symmetric keys in OmniLedger, protected by a
In short, Calypso allows to store symmetric keys in ByzCoin, protected by a
sharded key, and controls access to this symmetric keys using Darcs,
Distributed Access Rights Control.
It implements both the access-control cothority and the secret-management
cothority:
- The access-control cothority is implemented using OmniLedger with two
- The access-control cothority is implemented using ByzCoin with two
contracts, `calypsoWrite` and `calypsoRead`
- The secret-management cothority uses an onet service with methods to set up a
Long Term Secret (LTS) distributed key and to request a re-encryption
@@ -32,26 +32,26 @@ The workflow is the following:
6. secret-management: Reader requests a re-encryption to the `DecryptKey`
service endpoint.
![Workflow Overview](CalypsoOmniLedger.png?raw=true "Workflow Overview")
![Workflow Overview](CalypsoByzCoin.png?raw=true "Workflow Overview")
## Darcs, Instances, Instructions and Contracts
Here is a very short overview of the three most important elements of
OmniLedger. For a more thorough documentation, refer to
[OmniLedger](../omniledger/README.md) documentation.
ByzCoin. For a more thorough documentation, refer to
[ByzCoin](../byzcoin/README.md) documentation.
The current OmniLedger service is a batching implementation of the previous
The current ByzCoin service is a batching implementation of the previous
skipchain service. It has a global state that holds _Instances_, where every
instance is tied to a _Contract_ and holds a blob of data. The contract defines
how the data is to be interpreted and allows different _Instructions_ sent from
the user.
Access control is done using _Darcs_, which define what public keys can verify
an action. Each instruction received by OmniLedger is mapped to an action and
an action. Each instruction received by ByzCoin is mapped to an action and
then verified if the given signature is correct. Also, every instance is linked
to one darc that defines what actions are allowed to be done to that instance.
All instructions sent to OmniLedger are batched in a new block that is created
All instructions sent to ByzCoin are batched in a new block that is created
every `blockInterval` seconds.
## CreateLTS
@@ -73,7 +73,7 @@ that no malicious writer can send an encrypted key without knowing the secret.
It then creates a new write-instance that contains the write request.
A read request must also be sent to the write contract, which will forward it
to the read contract. This is so that every instruction sent to omniledger has
to the read contract. This is so that every instruction sent to ByzCoin has
as a target an existing instance.
## Read Contract
View
@@ -4,8 +4,8 @@ import (
"errors"
"github.com/dedis/cothority"
"github.com/dedis/cothority/byzcoin"
"github.com/dedis/cothority/byzcoin/darc"
ol "github.com/dedis/cothority/byzcoin/service"
"github.com/dedis/onet/log"
"github.com/dedis/onet/network"
"github.com/dedis/protobuf"
@@ -14,13 +14,13 @@ import (
// ContractWriteID references a write contract system-wide.
var ContractWriteID = "calypsoWrite"
// ContractWrite is used to store a secret in OmniLedger, so that an
// ContractWrite is used to store a secret in the ledger, so that an
// authorized reader can retrieve it by creating a Read-instance.
//
// Accepted Instructions:
// - spawn:calypsoWrite creates a new write-request. TODO: verify the LTS exists
// - spawn:calypsoRead creates a new read-request for this write-request.
func (s *Service) ContractWrite(cdb ol.CollectionView, inst ol.Instruction, c []ol.Coin) ([]ol.StateChange, []ol.Coin, error) {
func (s *Service) ContractWrite(cdb byzcoin.CollectionView, inst byzcoin.Instruction, c []byzcoin.Coin) ([]byzcoin.StateChange, []byzcoin.Coin, error) {
err := inst.VerifyDarcSignature(cdb)
if err != nil {
return nil, nil, err
@@ -33,8 +33,8 @@ func (s *Service) ContractWrite(cdb ol.CollectionView, inst ol.Instruction, c []
}
switch inst.GetType() {
case ol.SpawnType:
var sc ol.StateChanges
case byzcoin.SpawnType:
var sc byzcoin.StateChanges
nc := c
switch inst.Spawn.ContractID {
case ContractWriteID:
@@ -52,9 +52,9 @@ func (s *Service) ContractWrite(cdb ol.CollectionView, inst ol.Instruction, c []
}
instID := inst.DeriveID("")
log.Lvlf3("Successfully verified write request and will store in %x", instID)
sc = append(sc, ol.NewStateChange(ol.Create, instID, ContractWriteID, w, darcID))
sc = append(sc, byzcoin.NewStateChange(byzcoin.Create, instID, ContractWriteID, w, darcID))
case ContractReadID:
var scs ol.StateChanges
var scs byzcoin.StateChanges
var err error
scs, nc, err = s.ContractRead(cdb, inst, c)
if err != nil {
@@ -82,7 +82,7 @@ var ContractReadID = "calypsoRead"
// TODO: correctly handle multi signatures for read requests: to whom should the
// secret be re-encrypted to? Perhaps for multi signatures we only want to have
// ephemeral keys.
func (s *Service) ContractRead(cdb ol.CollectionView, inst ol.Instruction, c []ol.Coin) ([]ol.StateChange, []ol.Coin, error) {
func (s *Service) ContractRead(cdb byzcoin.CollectionView, inst byzcoin.Instruction, c []byzcoin.Coin) ([]byzcoin.StateChange, []byzcoin.Coin, error) {
err := inst.VerifyDarcSignature(cdb)
if err != nil {
return nil, nil, err
@@ -95,7 +95,7 @@ func (s *Service) ContractRead(cdb ol.CollectionView, inst ol.Instruction, c []o
}
switch inst.GetType() {
case ol.SpawnType:
case byzcoin.SpawnType:
if inst.Spawn.ContractID != ContractReadID {
return nil, nil, errors.New("can only spawn read instances")
}
@@ -115,7 +115,7 @@ func (s *Service) ContractRead(cdb ol.CollectionView, inst ol.Instruction, c []o
if cid != ContractWriteID {
return nil, nil, errors.New("referenced write-id is not a write instance, got " + cid)
}
return ol.StateChanges{ol.NewStateChange(ol.Create, inst.DeriveID(""), ContractReadID, r, darcID)}, c, nil
return byzcoin.StateChanges{byzcoin.NewStateChange(byzcoin.Create, inst.DeriveID(""), ContractReadID, r, darcID)}, c, nil
default:
return nil, nil, errors.New("not a spawn instruction")
}
View
@@ -1,9 +1,7 @@
package calypso
import (
// We need to use the omniledger import alias because it's the
// namespace used by protobuf is omniledger.
omniledger "github.com/dedis/cothority/byzcoin/service"
"github.com/dedis/cothority/byzcoin"
"github.com/dedis/cothority/skipchain"
"github.com/dedis/kyber"
"github.com/dedis/onet"
@@ -12,7 +10,7 @@ import (
// PROTOSTART
// type :skipchain.SkipBlockID:bytes
// package calypso;
// import "omniledger.proto";
// import "byzcoin.proto";
// import "onet.proto";
//
// option java_package = "ch.epfl.dedis.proto";
@@ -51,7 +49,7 @@ type Write struct {
// Read is the data stored in a read instance. It has a pointer to the write
// instance and the public key used to create the read instance.
type Read struct {
Write omniledger.InstanceID
Write byzcoin.InstanceID
Xc kyber.Point
}
@@ -63,8 +61,8 @@ type Read struct {
type CreateLTS struct {
// Roster is the list of nodes that should participate in the DKG.
Roster onet.Roster
// OLID is the ID of the OmniLedger that can use this LTS.
OLID skipchain.SkipBlockID
// BCID is the ID of the ByzCoin ledger that can use this LTS.
BCID skipchain.SkipBlockID
}
// CreateLTSReply is returned upon successfully setting up the distributed
@@ -79,12 +77,12 @@ type CreateLTSReply struct {
}
// DecryptKey is sent by a reader after he successfully stored a 'Read' request
// in omniledger.
// in byzcoin.
type DecryptKey struct {
// Read is the proof that he has been accepted to read the secret.
Read omniledger.Proof
Read byzcoin.Proof
// Write is the proof containing the write request.
Write omniledger.Proof
Write byzcoin.Proof
}
// DecryptKeyReply is returned if the service verified successfully that the
View
@@ -1,6 +1,6 @@
// Package calypso implements the LTS functionality of the Calypso paper. It
// implements both the access-control cothority and the secret management
// cothority. (1) The access-control cothority is implemented using OmniLedger
// cothority. (1) The access-control cothority is implemented using ByzCoin
// with two contracts, `Write` and `Read` (2) The secret-management cothority
// uses an onet service with methods to set up a Long Term Secret (LTS)
// distributed key and to request a re-encryption
@@ -15,10 +15,10 @@ import (
"time"
"github.com/dedis/cothority"
"github.com/dedis/cothority/byzcoin"
"github.com/dedis/cothority/byzcoin/darc"
dkgprotocol "github.com/dedis/cothority/dkg"
"github.com/dedis/cothority/ocs/protocol"
"github.com/dedis/cothority/byzcoin/darc"
ol "github.com/dedis/cothority/byzcoin/service"
"github.com/dedis/kyber"
"github.com/dedis/kyber/share"
"github.com/dedis/kyber/util/random"
@@ -60,7 +60,7 @@ type pubPoly struct {
// is non-nil, Signature needs to hold a valid signature from the reader
// in the Proof.
type vData struct {
Proof ol.Proof
Proof byzcoin.Proof
Ephemeral kyber.Point
Signature *darc.Signature
}
@@ -98,7 +98,7 @@ func (s *Service) CreateLTS(cl *CreateLTS) (reply *CreateLTSReply, err error) {
}
s.storage.Polys[string(reply.LTSID)] = &pubPoly{s.Suite().Point().Base(), dks.Commits}
s.storage.Rosters[string(reply.LTSID)] = &cl.Roster
s.storage.OLIDs[string(reply.LTSID)] = cl.OLID
s.storage.OLIDs[string(reply.LTSID)] = cl.BCID
s.storage.Unlock()
reply.X = shared.X
case <-time.After(propagationTimeout):
@@ -109,7 +109,7 @@ func (s *Service) CreateLTS(cl *CreateLTS) (reply *CreateLTSReply, err error) {
// DecryptKey takes as an input a Read- and a Write-proof. Proofs contain
// everything necessary to verify that a given instance is correct and
// stored in omniledger.
// stored in ByzCoin.
// Using the Read and the Write-instance, this method verifies that the
// requests match and then re-encrypts the secret to the public key given
// in the Read-instance.
@@ -126,7 +126,7 @@ func (s *Service) DecryptKey(dkr *DecryptKey) (reply *DecryptKeyReply, err error
if err := dkr.Write.ContractValue(cothority.Suite, ContractWriteID, &write); err != nil {
return nil, errors.New("didn't get a write instance: " + err.Error())
}
if !read.Write.Equal(ol.NewInstanceID(dkr.Write.InclusionProof.Key)) {
if !read.Write.Equal(byzcoin.NewInstanceID(dkr.Write.InclusionProof.Key)) {
return nil, errors.New("read doesn't point to passed write")
}
s.storage.Lock()
@@ -299,8 +299,8 @@ func newService(c *onet.Context) (onet.Service, error) {
if err := s.RegisterHandlers(s.CreateLTS, s.DecryptKey); err != nil {
return nil, errors.New("couldn't register messages")
}
ol.RegisterContract(c, ContractWriteID, s.ContractWrite)
ol.RegisterContract(c, ContractReadID, s.ContractRead)
byzcoin.RegisterContract(c, ContractWriteID, s.ContractWrite)
byzcoin.RegisterContract(c, ContractReadID, s.ContractRead)
if err := s.tryLoad(); err != nil {
log.Error(err)
return nil, err
Oops, something went wrong.

0 comments on commit c9511e2

Please sign in to comment.