Skip to content

Commit

Permalink
Reorganize merkletree pkg for repo consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
masomel committed Jul 22, 2016
1 parent 8e2f380 commit ae15fa3
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 48 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This license applies to all parts of the Merkle Prefix Tree Golang library except the following:
- Coname utility functions, located in internal/coname.go
- Coname utility functions, located in utils/coname.go
This module is copyrighted by the Coname Authors.
- The ed25519 subpackage, located in crypto/ed25519
This subpackage is copyrighted by the Go Authors.
Expand Down
52 changes: 22 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
[![Build Status](https://travis-ci.org/coniks-sys/libmerkleprefixtree-go.svg?branch=master)](https://travis-ci.org/coniks-sys/libmerkleprefixtree-go)
# CONIKS Go Library

# libmerkleprefixtree-go
A Merkle prefix tree implementation in Golang
[![Build Status](https://travis-ci.org/coniks-sys/coniks-go.svg?branch=master)](https://travis-ci.org/coniks-sys/coniks-go)

This library currently uses the `SHAKE128` ShakeHash with output size of 32 bytes.
https://coniks.org

The signature scheme is `Ed25519` signature algorithm.
##Introduction
CONIKS is a key management system that provides transparency and privacy
for end-user public keys.
CONIKS protects end-to-end encrypted communications against malicious or
compromised communication providers and surveillance by storing users'
encryption keys in tamper-evident and publicly auditable
key directories on the server side.
This allows messaging clients to verify the identity of
users automatically, and prevents malicious/compromised servers from
hijacking secure communications without getting caught.

### Usage
Initiate the history hash chain (the persistent authenticated dictionary)
```
// generate private key for STR signing
signKey := crypto.GenerateKey()
## Golang Library
The packages in this library implement the various components of the CONIKS system and may be imported individually.

// init STR history chain with maximum length is len
// using DefaultPolicies as current policy
pad := NewPAD(NewPolicies(epochDeadline), signKey, len)
```
- ``crypto``: Cryptographic algorithms and operations
- ``merkletree``: Merkle prefix tree and related data structures
- ``utils``: Utility functions

Update tree in each epoch
```
// insert new data
pad.Set(key, value)
...
// update STR history chain
// pass nil if the policies doesn't change
pad.Update(nil)
```
## Disclaimer
Please keep in mind that this CONIKS library is under active development. The repository may contain experimental features that aren't fully tested. We recommend using a [tagged release](https://github.com/coniks-sys/coniks-go/releases).

Look-up

`LookUp(key)` and `LookUpInEpoch(key, epoch)` return a `MerkleNode` instance and an `AuthenticationPath` for proofs of inclusion/absence.
A proof of absence also includes an empty leaf node in the returned auth path.

### TODO
Some methods/functions should be exported in the future when the library is being used in real applications.
##Documentation
Coming soon!
2 changes: 1 addition & 1 deletion crypto/ed25519/extra25519/extra25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package extra25519
import (
"crypto/sha512"

"github.com/coniks-sys/libmerkleprefixtree-go/crypto/ed25519/edwards25519"
"github.com/coniks-sys/coniks-go/crypto/ed25519/edwards25519"
)

// PrivateKeyToCurve25519 converts an ed25519 private key into a corresponding
Expand Down
2 changes: 1 addition & 1 deletion crypto/ed25519/extra25519/extra25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"crypto/sha512"
"testing"

"github.com/coniks-sys/libmerkleprefixtree-go/crypto/ed25519/edwards25519"
"github.com/coniks-sys/coniks-go/crypto/ed25519/edwards25519"
"golang.org/x/crypto/curve25519"
"golang.org/x/crypto/ed25519"
)
Expand Down
4 changes: 2 additions & 2 deletions crypto/vrf/vrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

"golang.org/x/crypto/sha3"

"github.com/coniks-sys/libmerkleprefixtree-go/crypto/ed25519/edwards25519"
"github.com/coniks-sys/libmerkleprefixtree-go/crypto/ed25519/extra25519"
"github.com/coniks-sys/coniks-go/crypto/ed25519/edwards25519"
"github.com/coniks-sys/coniks-go/crypto/ed25519/extra25519"
)

const (
Expand Down
33 changes: 33 additions & 0 deletions merkletree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Merkle Tree
This package contains the CONIKS Merkle prefix tree implementation

We use the `SHAKE128` ShakeHash with output size of 32 bytes, and the signature scheme is `Ed25519` signature algorithm. See our [crypto package](https://github.com/coniks-sys/coniks-go/tree/master/crypto) for details and the implementation used.

### Usage
Initiate the history hash chain (the persistent authenticated dictionary)
```
// generate private key for STR signing
signKey := crypto.GenerateKey()
// init STR history chain with maximum length is len
// using DefaultPolicies as current policy
pad := NewPAD(NewPolicies(epochDeadline), signKey, len)
```

Update tree in each epoch
```
// insert new data
pad.Set(key, value)
...
// update STR history chain
// pass nil if the policies doesn't change
pad.Update(nil)
```

Look-up

`LookUp(key)` and `LookUpInEpoch(key, epoch)` return a `MerkleNode` instance and an `AuthenticationPath` for proofs of inclusion/absence.
A proof of absence also includes an empty leaf node in the returned auth path.

### TODO
Some methods/functions should be exported in the future when the library is being used in real applications.
4 changes: 2 additions & 2 deletions merkletree.go → merkletree/merkletree.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"crypto/rand"
"errors"

"github.com/coniks-sys/libmerkleprefixtree-go/crypto"
"github.com/coniks-sys/libmerkleprefixtree-go/internal"
"github.com/coniks-sys/coniks-go/crypto"
"github.com/coniks-sys/coniks-go/utils"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion merkletree_test.go → merkletree/merkletree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"testing"

"github.com/coniks-sys/libmerkleprefixtree-go/internal"
"github.com/coniks-sys/coniks-go/utils"
"golang.org/x/crypto/sha3"
)

Expand Down
4 changes: 2 additions & 2 deletions node.go → merkletree/node.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package merkletree

import (
"github.com/coniks-sys/libmerkleprefixtree-go/crypto"
"github.com/coniks-sys/libmerkleprefixtree-go/internal"
"github.com/coniks-sys/coniks-go/crypto"
"github.com/coniks-sys/coniks-go/utils"
)

type node struct {
Expand Down
2 changes: 1 addition & 1 deletion pad.go → merkletree/pad.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"crypto/rand"
"errors"

"github.com/coniks-sys/libmerkleprefixtree-go/crypto"
"github.com/coniks-sys/coniks-go/crypto"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion pad_test.go → merkletree/pad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"testing"

"github.com/coniks-sys/libmerkleprefixtree-go/crypto"
"github.com/coniks-sys/coniks-go/crypto"
)

var signKey crypto.SigningKey
Expand Down
4 changes: 2 additions & 2 deletions policy.go → merkletree/policy.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package merkletree

import (
"github.com/coniks-sys/libmerkleprefixtree-go/crypto"
"github.com/coniks-sys/libmerkleprefixtree-go/internal"
"github.com/coniks-sys/coniks-go/crypto"
"github.com/coniks-sys/coniks-go/utils"
)

type TimeStamp uint64
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions proof_test.go → merkletree/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"testing"

"github.com/coniks-sys/libmerkleprefixtree-go/crypto"
"github.com/coniks-sys/libmerkleprefixtree-go/internal"
"github.com/coniks-sys/coniks-go/crypto"
"github.com/coniks-sys/coniks-go/utils"
)

func computeLeafHash(ap *AuthenticationPath) (leafHash []byte) {
Expand Down
4 changes: 2 additions & 2 deletions str.go → merkletree/str.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package merkletree
import (
"errors"

"github.com/coniks-sys/libmerkleprefixtree-go/crypto"
"github.com/coniks-sys/libmerkleprefixtree-go/internal"
"github.com/coniks-sys/coniks-go/crypto"
"github.com/coniks-sys/coniks-go/utils"
)

var (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ae15fa3

Please sign in to comment.