@ -1,42 +0,0 @@ | |||
<!-- Thanks for filing an issue! Before hitting the button, please answer these questions.--> | |||
**Is this a BUG REPORT or FEATURE REQUEST?** (choose one): | |||
<!-- | |||
If this is a BUG REPORT, please: | |||
- Fill in as much of the template below as you can. | |||
If this is a FEATURE REQUEST, please: | |||
- Describe *in detail* the feature/behavior/change you'd like to see. | |||
In both cases, be ready for followup questions, and please respond in a timely | |||
manner. We might ask you to provide additional logs and data (tendermint & app) | |||
in a case of bug. | |||
--> | |||
**Tendermint version** (use `tendermint version` or `git rev-parse --verify HEAD` if installed from source): | |||
**ABCI app** (name for built-in, URL for self-written if it's publicly available): | |||
**Environment**: | |||
- **OS** (e.g. from /etc/os-release): | |||
- **Install tools**: | |||
- **Others**: | |||
**What happened**: | |||
**What you expected to happen**: | |||
**How to reproduce it** (as minimally and precisely as possible): | |||
**Logs (you can paste a small part showing an error or link a pastebin, gist, etc. containing more of the log file)**: | |||
**Config (you can paste only the changes you've made)**: | |||
**`/dump_consensus_state` output for consensus bugs** | |||
**Anything else do we need to know**: |
@ -0,0 +1,38 @@ | |||
--- | |||
name: Bug Report | |||
about: Create a report to help us squash bugs! | |||
--- | |||
<!-- | |||
Please fill in as much of the template below as you can. | |||
Be ready for followup questions, and please respond in a timely | |||
manner. We might ask you to provide additional logs and data (tendermint & app). | |||
--> | |||
**Tendermint version** (use `tendermint version` or `git rev-parse --verify HEAD` if installed from source): | |||
**ABCI app** (name for built-in, URL for self-written if it's publicly available): | |||
**Environment**: | |||
- **OS** (e.g. from /etc/os-release): | |||
- **Install tools**: | |||
- **Others**: | |||
**What happened**: | |||
**What you expected to happen**: | |||
**How to reproduce it** (as minimally and precisely as possible): | |||
**Logs (paste a small part showing an error (< 10 lines) or link a pastebin, gist, etc. containing more of the log file)**: | |||
**Config (you can paste only the changes you've made)**: | |||
**`/dump_consensus_state` output for consensus bugs** | |||
**Anything else we need to know**: |
@ -0,0 +1,13 @@ | |||
--- | |||
name: Feature Request | |||
about: Create a proposal to request a feature | |||
--- | |||
<!-- | |||
Please describe *in detail* the feature/behavior/change you'd like to see. | |||
Be ready for followup questions, and please respond in a timely | |||
manner. | |||
Word of caution: poorly thought out proposals may be rejected without deliberation | |||
--> |
@ -0,0 +1,26 @@ | |||
package ed25519 | |||
import ( | |||
"io" | |||
"testing" | |||
"github.com/tendermint/tendermint/crypto" | |||
"github.com/tendermint/tendermint/crypto/internal/benchmarking" | |||
) | |||
func BenchmarkKeyGeneration(b *testing.B) { | |||
benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { | |||
return genPrivKey(reader) | |||
} | |||
benchmarking.BenchmarkKeyGeneration(b, benchmarkKeygenWrapper) | |||
} | |||
func BenchmarkSigning(b *testing.B) { | |||
priv := GenPrivKey() | |||
benchmarking.BenchmarkSigning(b, priv) | |||
} | |||
func BenchmarkVerification(b *testing.B) { | |||
priv := GenPrivKey() | |||
benchmarking.BenchmarkVerification(b, priv) | |||
} |
@ -1,106 +0,0 @@ | |||
// Package hkdfchacha20poly1305 creates an AEAD using hkdf, chacha20, and poly1305 | |||
// When sealing and opening, the hkdf is used to obtain the nonce and subkey for | |||
// chacha20. Other than the change for the how the subkey and nonce for chacha | |||
// are obtained, this is the same as chacha20poly1305 | |||
package hkdfchacha20poly1305 | |||
import ( | |||
"crypto/cipher" | |||
"crypto/sha256" | |||
"errors" | |||
"io" | |||
"golang.org/x/crypto/chacha20poly1305" | |||
"golang.org/x/crypto/hkdf" | |||
) | |||
// Implements crypto.AEAD | |||
type hkdfchacha20poly1305 struct { | |||
key [KeySize]byte | |||
} | |||
const ( | |||
// KeySize is the size of the key used by this AEAD, in bytes. | |||
KeySize = 32 | |||
// NonceSize is the size of the nonce used with this AEAD, in bytes. | |||
NonceSize = 24 | |||
// TagSize is the size added from poly1305 | |||
TagSize = 16 | |||
// MaxPlaintextSize is the max size that can be passed into a single call of Seal | |||
MaxPlaintextSize = (1 << 38) - 64 | |||
// MaxCiphertextSize is the max size that can be passed into a single call of Open, | |||
// this differs from plaintext size due to the tag | |||
MaxCiphertextSize = (1 << 38) - 48 | |||
// HkdfInfo is the parameter used internally for Hkdf's info parameter. | |||
HkdfInfo = "TENDERMINT_SECRET_CONNECTION_FRAME_KEY_DERIVE" | |||
) | |||
//New xChaChapoly1305 AEAD with 24 byte nonces | |||
func New(key []byte) (cipher.AEAD, error) { | |||
if len(key) != KeySize { | |||
return nil, errors.New("chacha20poly1305: bad key length") | |||
} | |||
ret := new(hkdfchacha20poly1305) | |||
copy(ret.key[:], key) | |||
return ret, nil | |||
} | |||
func (c *hkdfchacha20poly1305) NonceSize() int { | |||
return NonceSize | |||
} | |||
func (c *hkdfchacha20poly1305) Overhead() int { | |||
return TagSize | |||
} | |||
func (c *hkdfchacha20poly1305) Seal(dst, nonce, plaintext, additionalData []byte) []byte { | |||
if len(nonce) != NonceSize { | |||
panic("hkdfchacha20poly1305: bad nonce length passed to Seal") | |||
} | |||
if uint64(len(plaintext)) > MaxPlaintextSize { | |||
panic("hkdfchacha20poly1305: plaintext too large") | |||
} | |||
subKey, chachaNonce := getSubkeyAndChachaNonceFromHkdf(&c.key, &nonce) | |||
aead, err := chacha20poly1305.New(subKey[:]) | |||
if err != nil { | |||
panic("hkdfchacha20poly1305: failed to initialize chacha20poly1305") | |||
} | |||
return aead.Seal(dst, chachaNonce[:], plaintext, additionalData) | |||
} | |||
func (c *hkdfchacha20poly1305) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { | |||
if len(nonce) != NonceSize { | |||
return nil, errors.New("hkdfchacha20poly1305: bad nonce length passed to Open") | |||
} | |||
if uint64(len(ciphertext)) > MaxCiphertextSize { | |||
return nil, errors.New("hkdfchacha20poly1305: ciphertext too large") | |||
} | |||
subKey, chachaNonce := getSubkeyAndChachaNonceFromHkdf(&c.key, &nonce) | |||
aead, err := chacha20poly1305.New(subKey[:]) | |||
if err != nil { | |||
panic("hkdfchacha20poly1305: failed to initialize chacha20poly1305") | |||
} | |||
return aead.Open(dst, chachaNonce[:], ciphertext, additionalData) | |||
} | |||
func getSubkeyAndChachaNonceFromHkdf(cKey *[32]byte, nonce *[]byte) ( | |||
subKey [KeySize]byte, chachaNonce [chacha20poly1305.NonceSize]byte) { | |||
hash := sha256.New | |||
hkdf := hkdf.New(hash, (*cKey)[:], *nonce, []byte(HkdfInfo)) | |||
_, err := io.ReadFull(hkdf, subKey[:]) | |||
if err != nil { | |||
panic("hkdfchacha20poly1305: failed to read subkey from hkdf") | |||
} | |||
_, err = io.ReadFull(hkdf, chachaNonce[:]) | |||
if err != nil { | |||
panic("hkdfchacha20poly1305: failed to read chachaNonce from hkdf") | |||
} | |||
return | |||
} |
@ -0,0 +1,88 @@ | |||
package benchmarking | |||
import ( | |||
"io" | |||
"testing" | |||
"github.com/tendermint/tendermint/crypto" | |||
) | |||
// The code in this file is adapted from agl/ed25519. | |||
// As such it is under the following license. | |||
// Copyright 2012 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found at the bottom of this file. | |||
type zeroReader struct{} | |||
func (zeroReader) Read(buf []byte) (int, error) { | |||
for i := range buf { | |||
buf[i] = 0 | |||
} | |||
return len(buf), nil | |||
} | |||
// BenchmarkKeyGeneration benchmarks the given key generation algorithm using | |||
// a dummy reader. | |||
func BenchmarkKeyGeneration(b *testing.B, GenerateKey func(reader io.Reader) crypto.PrivKey) { | |||
var zero zeroReader | |||
for i := 0; i < b.N; i++ { | |||
GenerateKey(zero) | |||
} | |||
} | |||
// BenchmarkSigning benchmarks the given signing algorithm using | |||
// the provided privkey. | |||
func BenchmarkSigning(b *testing.B, priv crypto.PrivKey) { | |||
message := []byte("Hello, world!") | |||
b.ResetTimer() | |||
for i := 0; i < b.N; i++ { | |||
priv.Sign(message) | |||
} | |||
} | |||
// BenchmarkVerification benchmarks the given verification algorithm using | |||
// the provided privkey on a constant message. | |||
func BenchmarkVerification(b *testing.B, priv crypto.PrivKey) { | |||
pub := priv.PubKey() | |||
// use a short message, so this time doesn't get dominated by hashing. | |||
message := []byte("Hello, world!") | |||
signature, err := priv.Sign(message) | |||
if err != nil { | |||
b.Fatal(err) | |||
} | |||
b.ResetTimer() | |||
for i := 0; i < b.N; i++ { | |||
pub.VerifyBytes(message, signature) | |||
} | |||
} | |||
// Below is the aforementioned license. | |||
// Copyright (c) 2012 The Go Authors. All rights reserved. | |||
// Redistribution and use in source and binary forms, with or without | |||
// modification, are permitted provided that the following conditions are | |||
// met: | |||
// * Redistributions of source code must retain the above copyright | |||
// notice, this list of conditions and the following disclaimer. | |||
// * Redistributions in binary form must reproduce the above | |||
// copyright notice, this list of conditions and the following disclaimer | |||
// in the documentation and/or other materials provided with the | |||
// distribution. | |||
// * Neither the name of Google Inc. nor the names of its | |||
// contributors may be used to endorse or promote products derived from | |||
// this software without specific prior written permission. | |||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
@ -0,0 +1,26 @@ | |||
package secp256k1 | |||
import ( | |||
"io" | |||
"testing" | |||
"github.com/tendermint/tendermint/crypto" | |||
"github.com/tendermint/tendermint/crypto/internal/benchmarking" | |||
) | |||
func BenchmarkKeyGeneration(b *testing.B) { | |||
benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { | |||
return genPrivKey(reader) | |||
} | |||
benchmarking.BenchmarkKeyGeneration(b, benchmarkKeygenWrapper) | |||
} | |||
func BenchmarkSigning(b *testing.B) { | |||
priv := GenPrivKey() | |||
benchmarking.BenchmarkSigning(b, priv) | |||
} | |||
func BenchmarkVerification(b *testing.B) { | |||
priv := GenPrivKey() | |||
benchmarking.BenchmarkVerification(b, priv) | |||
} |
@ -0,0 +1,103 @@ | |||
package xchacha20poly1305 | |||
import ( | |||
"bytes" | |||
"encoding/hex" | |||
"testing" | |||
) | |||
func toHex(bits []byte) string { | |||
return hex.EncodeToString(bits) | |||
} | |||
func fromHex(bits string) []byte { | |||
b, err := hex.DecodeString(bits) | |||
if err != nil { | |||
panic(err) | |||
} | |||
return b | |||
} | |||
func TestHChaCha20(t *testing.T) { | |||
for i, v := range hChaCha20Vectors { | |||
var key [32]byte | |||
var nonce [16]byte | |||
copy(key[:], v.key) | |||
copy(nonce[:], v.nonce) | |||
HChaCha20(&key, &nonce, &key) | |||
if !bytes.Equal(key[:], v.keystream) { | |||
t.Errorf("Test %d: keystream mismatch:\n \t got: %s\n \t want: %s", i, toHex(key[:]), toHex(v.keystream)) | |||
} | |||
} | |||
} | |||
var hChaCha20Vectors = []struct { | |||
key, nonce, keystream []byte | |||
}{ | |||
{ | |||
fromHex("0000000000000000000000000000000000000000000000000000000000000000"), | |||
fromHex("000000000000000000000000000000000000000000000000"), | |||
fromHex("1140704c328d1d5d0e30086cdf209dbd6a43b8f41518a11cc387b669b2ee6586"), | |||
}, | |||
{ | |||
fromHex("8000000000000000000000000000000000000000000000000000000000000000"), | |||
fromHex("000000000000000000000000000000000000000000000000"), | |||
fromHex("7d266a7fd808cae4c02a0a70dcbfbcc250dae65ce3eae7fc210f54cc8f77df86"), | |||
}, | |||
{ | |||
fromHex("0000000000000000000000000000000000000000000000000000000000000001"), | |||
fromHex("000000000000000000000000000000000000000000000002"), | |||
fromHex("e0c77ff931bb9163a5460c02ac281c2b53d792b1c43fea817e9ad275ae546963"), | |||
}, | |||
{ | |||
fromHex("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"), | |||
fromHex("000102030405060708090a0b0c0d0e0f1011121314151617"), | |||
fromHex("51e3ff45a895675c4b33b46c64f4a9ace110d34df6a2ceab486372bacbd3eff6"), | |||
}, | |||
{ | |||
fromHex("24f11cce8a1b3d61e441561a696c1c1b7e173d084fd4812425435a8896a013dc"), | |||
fromHex("d9660c5900ae19ddad28d6e06e45fe5e"), | |||
fromHex("5966b3eec3bff1189f831f06afe4d4e3be97fa9235ec8c20d08acfbbb4e851e3"), | |||
}, | |||
} | |||
func TestVectors(t *testing.T) { | |||
for i, v := range vectors { | |||
if len(v.plaintext) == 0 { | |||
v.plaintext = make([]byte, len(v.ciphertext)) | |||
} | |||
var nonce [24]byte | |||
copy(nonce[:], v.nonce) | |||
aead, err := New(v.key) | |||
if err != nil { | |||
t.Error(err) | |||
} | |||
dst := aead.Seal(nil, nonce[:], v.plaintext, v.ad) | |||
if !bytes.Equal(dst, v.ciphertext) { | |||
t.Errorf("Test %d: ciphertext mismatch:\n \t got: %s\n \t want: %s", i, toHex(dst), toHex(v.ciphertext)) | |||
} | |||
open, err := aead.Open(nil, nonce[:], dst, v.ad) | |||
if err != nil { | |||
t.Error(err) | |||
} | |||
if !bytes.Equal(open, v.plaintext) { | |||
t.Errorf("Test %d: plaintext mismatch:\n \t got: %s\n \t want: %s", i, string(open), string(v.plaintext)) | |||
} | |||
} | |||
} | |||
var vectors = []struct { | |||
key, nonce, ad, plaintext, ciphertext []byte | |||
}{ | |||
{ | |||
[]byte{0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f}, | |||
[]byte{0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b}, | |||
[]byte{0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7}, | |||
[]byte("Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."), | |||
[]byte{0x45, 0x3c, 0x06, 0x93, 0xa7, 0x40, 0x7f, 0x04, 0xff, 0x4c, 0x56, 0xae, 0xdb, 0x17, 0xa3, 0xc0, 0xa1, 0xaf, 0xff, 0x01, 0x17, 0x49, 0x30, 0xfc, 0x22, 0x28, 0x7c, 0x33, 0xdb, 0xcf, 0x0a, 0xc8, 0xb8, 0x9a, 0xd9, 0x29, 0x53, 0x0a, 0x1b, 0xb3, 0xab, 0x5e, 0x69, 0xf2, 0x4c, 0x7f, 0x60, 0x70, 0xc8, 0xf8, 0x40, 0xc9, 0xab, 0xb4, 0xf6, 0x9f, 0xbf, 0xc8, 0xa7, 0xff, 0x51, 0x26, 0xfa, 0xee, 0xbb, 0xb5, 0x58, 0x05, 0xee, 0x9c, 0x1c, 0xf2, 0xce, 0x5a, 0x57, 0x26, 0x32, 0x87, 0xae, 0xc5, 0x78, 0x0f, 0x04, 0xec, 0x32, 0x4c, 0x35, 0x14, 0x12, 0x2c, 0xfc, 0x32, 0x31, 0xfc, 0x1a, 0x8b, 0x71, 0x8a, 0x62, 0x86, 0x37, 0x30, 0xa2, 0x70, 0x2b, 0xb7, 0x63, 0x66, 0x11, 0x6b, 0xed, 0x09, 0xe0, 0xfd, 0x5c, 0x6d, 0x84, 0xb6, 0xb0, 0xc1, 0xab, 0xaf, 0x24, 0x9d, 0x5d, 0xd0, 0xf7, 0xf5, 0xa7, 0xea}, | |||
}, | |||
} |
@ -0,0 +1,261 @@ | |||
// Package xchacha20poly1305 creates an AEAD using hchacha, chacha, and poly1305 | |||
// This allows for randomized nonces to be used in conjunction with chacha. | |||
package xchacha20poly1305 | |||
import ( | |||
"crypto/cipher" | |||
"encoding/binary" | |||
"errors" | |||
"fmt" | |||
"golang.org/x/crypto/chacha20poly1305" | |||
) | |||
// Implements crypto.AEAD | |||
type xchacha20poly1305 struct { | |||
key [KeySize]byte | |||
} | |||
const ( | |||
// KeySize is the size of the key used by this AEAD, in bytes. | |||
KeySize = 32 | |||
// NonceSize is the size of the nonce used with this AEAD, in bytes. | |||
NonceSize = 24 | |||
// TagSize is the size added from poly1305 | |||
TagSize = 16 | |||
// MaxPlaintextSize is the max size that can be passed into a single call of Seal | |||
MaxPlaintextSize = (1 << 38) - 64 | |||
// MaxCiphertextSize is the max size that can be passed into a single call of Open, | |||
// this differs from plaintext size due to the tag | |||
MaxCiphertextSize = (1 << 38) - 48 | |||
// sigma are constants used in xchacha. | |||
// Unrolled from a slice so that they can be inlined, as slices can't be constants. | |||
sigma0 = uint32(0x61707865) | |||
sigma1 = uint32(0x3320646e) | |||
sigma2 = uint32(0x79622d32) | |||
sigma3 = uint32(0x6b206574) | |||
) | |||
// New returns a new xchachapoly1305 AEAD | |||
func New(key []byte) (cipher.AEAD, error) { | |||
if len(key) != KeySize { | |||
return nil, errors.New("xchacha20poly1305: bad key length") | |||
} | |||
ret := new(xchacha20poly1305) | |||
copy(ret.key[:], key) | |||
return ret, nil | |||
} | |||
// nolint | |||
func (c *xchacha20poly1305) NonceSize() int { | |||
return NonceSize | |||
} | |||
// nolint | |||
func (c *xchacha20poly1305) Overhead() int { | |||
return TagSize | |||
} | |||
func (c *xchacha20poly1305) Seal(dst, nonce, plaintext, additionalData []byte) []byte { | |||
if len(nonce) != NonceSize { | |||
panic("xchacha20poly1305: bad nonce length passed to Seal") | |||
} | |||
if uint64(len(plaintext)) > MaxPlaintextSize { | |||
panic("xchacha20poly1305: plaintext too large") | |||
} | |||
var subKey [KeySize]byte | |||
var hNonce [16]byte | |||
var subNonce [chacha20poly1305.NonceSize]byte | |||
copy(hNonce[:], nonce[:16]) | |||
HChaCha20(&subKey, &hNonce, &c.key) | |||
// This can't error because we always provide a correctly sized key | |||
chacha20poly1305, _ := chacha20poly1305.New(subKey[:]) | |||
copy(subNonce[4:], nonce[16:]) | |||
return chacha20poly1305.Seal(dst, subNonce[:], plaintext, additionalData) | |||
} | |||
func (c *xchacha20poly1305) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { | |||
if len(nonce) != NonceSize { | |||
return nil, fmt.Errorf("xchacha20poly1305: bad nonce length passed to Open") | |||
} | |||
if uint64(len(ciphertext)) > MaxCiphertextSize { | |||
return nil, fmt.Errorf("xchacha20poly1305: ciphertext too large") | |||
} | |||
var subKey [KeySize]byte | |||
var hNonce [16]byte | |||
var subNonce [chacha20poly1305.NonceSize]byte | |||
copy(hNonce[:], nonce[:16]) | |||
HChaCha20(&subKey, &hNonce, &c.key) | |||
// This can't error because we always provide a correctly sized key | |||
chacha20poly1305, _ := chacha20poly1305.New(subKey[:]) | |||
copy(subNonce[4:], nonce[16:]) | |||
return chacha20poly1305.Open(dst, subNonce[:], ciphertext, additionalData) | |||
} | |||
// HChaCha exported from | |||
// https://github.com/aead/chacha20/blob/8b13a72661dae6e9e5dea04f344f0dc95ea29547/chacha/chacha_generic.go#L194 | |||
// TODO: Add support for the different assembly instructions used there. | |||
// The MIT License (MIT) | |||
// Copyright (c) 2016 Andreas Auernhammer | |||
// Permission is hereby granted, free of charge, to any person obtaining a copy | |||
// of this software and associated documentation files (the "Software"), to deal | |||
// in the Software without restriction, including without limitation the rights | |||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
// copies of the Software, and to permit persons to whom the Software is | |||
// furnished to do so, subject to the following conditions: | |||
// The above copyright notice and this permission notice shall be included in all | |||
// copies or substantial portions of the Software. | |||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||
// SOFTWARE. | |||
// HChaCha20 generates 32 pseudo-random bytes from a 128 bit nonce and a 256 bit secret key. | |||
// It can be used as a key-derivation-function (KDF). | |||
func HChaCha20(out *[32]byte, nonce *[16]byte, key *[32]byte) { hChaCha20Generic(out, nonce, key) } | |||
func hChaCha20Generic(out *[32]byte, nonce *[16]byte, key *[32]byte) { | |||
v00 := sigma0 | |||
v01 := sigma1 | |||
v02 := sigma2 | |||
v03 := sigma3 | |||
v04 := binary.LittleEndian.Uint32(key[0:]) | |||
v05 := binary.LittleEndian.Uint32(key[4:]) | |||
v06 := binary.LittleEndian.Uint32(key[8:]) | |||
v07 := binary.LittleEndian.Uint32(key[12:]) | |||
v08 := binary.LittleEndian.Uint32(key[16:]) | |||
v09 := binary.LittleEndian.Uint32(key[20:]) | |||
v10 := binary.LittleEndian.Uint32(key[24:]) | |||
v11 := binary.LittleEndian.Uint32(key[28:]) | |||
v12 := binary.LittleEndian.Uint32(nonce[0:]) | |||
v13 := binary.LittleEndian.Uint32(nonce[4:]) | |||
v14 := binary.LittleEndian.Uint32(nonce[8:]) | |||
v15 := binary.LittleEndian.Uint32(nonce[12:]) | |||
for i := 0; i < 20; i += 2 { | |||
v00 += v04 | |||
v12 ^= v00 | |||
v12 = (v12 << 16) | (v12 >> 16) | |||
v08 += v12 | |||
v04 ^= v08 | |||
v04 = (v04 << 12) | (v04 >> 20) | |||
v00 += v04 | |||
v12 ^= v00 | |||
v12 = (v12 << 8) | (v12 >> 24) | |||
v08 += v12 | |||
v04 ^= v08 | |||
v04 = (v04 << 7) | (v04 >> 25) | |||
v01 += v05 | |||
v13 ^= v01 | |||
v13 = (v13 << 16) | (v13 >> 16) | |||
v09 += v13 | |||
v05 ^= v09 | |||
v05 = (v05 << 12) | (v05 >> 20) | |||
v01 += v05 | |||
v13 ^= v01 | |||
v13 = (v13 << 8) | (v13 >> 24) | |||
v09 += v13 | |||
v05 ^= v09 | |||
v05 = (v05 << 7) | (v05 >> 25) | |||
v02 += v06 | |||
v14 ^= v02 | |||
v14 = (v14 << 16) | (v14 >> 16) | |||
v10 += v14 | |||
v06 ^= v10 | |||
v06 = (v06 << 12) | (v06 >> 20) | |||
v02 += v06 | |||
v14 ^= v02 | |||
v14 = (v14 << 8) | (v14 >> 24) | |||
v10 += v14 | |||
v06 ^= v10 | |||
v06 = (v06 << 7) | (v06 >> 25) | |||
v03 += v07 | |||
v15 ^= v03 | |||
v15 = (v15 << 16) | (v15 >> 16) | |||
v11 += v15 | |||
v07 ^= v11 | |||
v07 = (v07 << 12) | (v07 >> 20) | |||
v03 += v07 | |||
v15 ^= v03 | |||
v15 = (v15 << 8) | (v15 >> 24) | |||
v11 += v15 | |||
v07 ^= v11 | |||
v07 = (v07 << 7) | (v07 >> 25) | |||
v00 += v05 | |||
v15 ^= v00 | |||
v15 = (v15 << 16) | (v15 >> 16) | |||
v10 += v15 | |||
v05 ^= v10 | |||
v05 = (v05 << 12) | (v05 >> 20) | |||
v00 += v05 | |||
v15 ^= v00 | |||
v15 = (v15 << 8) | (v15 >> 24) | |||
v10 += v15 | |||
v05 ^= v10 | |||
v05 = (v05 << 7) | (v05 >> 25) | |||
v01 += v06 | |||
v12 ^= v01 | |||
v12 = (v12 << 16) | (v12 >> 16) | |||
v11 += v12 | |||
v06 ^= v11 | |||
v06 = (v06 << 12) | (v06 >> 20) | |||
v01 += v06 | |||
v12 ^= v01 | |||
v12 = (v12 << 8) | (v12 >> 24) | |||
v11 += v12 | |||
v06 ^= v11 | |||
v06 = (v06 << 7) | (v06 >> 25) | |||
v02 += v07 | |||
v13 ^= v02 | |||
v13 = (v13 << 16) | (v13 >> 16) | |||
v08 += v13 | |||
v07 ^= v08 | |||
v07 = (v07 << 12) | (v07 >> 20) | |||
v02 += v07 | |||
v13 ^= v02 | |||
v13 = (v13 << 8) | (v13 >> 24) | |||
v08 += v13 | |||
v07 ^= v08 | |||
v07 = (v07 << 7) | (v07 >> 25) | |||
v03 += v04 | |||
v14 ^= v03 | |||
v14 = (v14 << 16) | (v14 >> 16) | |||
v09 += v14 | |||
v04 ^= v09 | |||
v04 = (v04 << 12) | (v04 >> 20) | |||
v03 += v04 | |||
v14 ^= v03 | |||
v14 = (v14 << 8) | (v14 >> 24) | |||
v09 += v14 | |||
v04 ^= v09 | |||
v04 = (v04 << 7) | (v04 >> 25) | |||
} | |||
binary.LittleEndian.PutUint32(out[0:], v00) | |||
binary.LittleEndian.PutUint32(out[4:], v01) | |||
binary.LittleEndian.PutUint32(out[8:], v02) | |||
binary.LittleEndian.PutUint32(out[12:], v03) | |||
binary.LittleEndian.PutUint32(out[16:], v12) | |||
binary.LittleEndian.PutUint32(out[20:], v13) | |||
binary.LittleEndian.PutUint32(out[24:], v14) | |||
binary.LittleEndian.PutUint32(out[28:], v15) | |||
} |
@ -0,0 +1,113 @@ | |||
# ADR 012: PeerTransport | |||
## Context | |||
One of the more apparent problems with the current architecture in the p2p | |||
package is that there is no clear separation of concerns between different | |||
components. Most notably the `Switch` is currently doing physical connection | |||
handling. An artifact is the dependency of the Switch on | |||
`[config.P2PConfig`](https://github.com/tendermint/tendermint/blob/05a76fb517f50da27b4bfcdc7b4cf185fc61eff6/config/config.go#L272-L339). | |||
Addresses: | |||
* [#2046](https://github.com/tendermint/tendermint/issues/2046) | |||
* [#2047](https://github.com/tendermint/tendermint/issues/2047) | |||
First iteraton in [#2067](https://github.com/tendermint/tendermint/issues/2067) | |||
## Decision | |||
Transport concerns will be handled by a new component (`PeerTransport`) which | |||
will provide Peers at its boundary to the caller. In turn `Switch` will use | |||
this new component accept new `Peer`s and dial them based on `NetAddress`. | |||
### PeerTransport | |||
Responsible for emitting and connecting to Peers. The implementation of `Peer` | |||
is left to the transport, which implies that the chosen transport dictates the | |||
characteristics of the implementation handed back to the `Switch`. Each | |||
transport implementation is responsible to filter establishing peers specific | |||
to its domain, for the default multiplexed implementation the following will | |||
apply: | |||
* connections from our own node | |||
* handshake fails | |||
* upgrade to secret connection fails | |||
* prevent duplicate ip | |||
* prevent duplicate id | |||
* nodeinfo incompatibility | |||
``` go | |||
// PeerTransport proxies incoming and outgoing peer connections. | |||
type PeerTransport interface { | |||
// Accept returns a newly connected Peer. | |||
Accept() (Peer, error) | |||
// Dial connects to a Peer. | |||
Dial(NetAddress) (Peer, error) | |||
} | |||
// EXAMPLE OF DEFAULT IMPLEMENTATION | |||
// multiplexTransport accepts tcp connections and upgrades to multiplexted | |||
// peers. | |||
type multiplexTransport struct { | |||
listener net.Listener | |||
acceptc chan accept | |||
closec <-chan struct{} | |||
listenc <-chan struct{} | |||
dialTimeout time.Duration | |||
handshakeTimeout time.Duration | |||
nodeAddr NetAddress | |||
nodeInfo NodeInfo | |||
nodeKey NodeKey | |||
// TODO(xla): Remove when MConnection is refactored into mPeer. | |||
mConfig conn.MConnConfig | |||
} | |||
var _ PeerTransport = (*multiplexTransport)(nil) | |||
// NewMTransport returns network connected multiplexed peers. | |||
func NewMTransport( | |||
nodeAddr NetAddress, | |||
nodeInfo NodeInfo, | |||
nodeKey NodeKey, | |||
) *multiplexTransport | |||
``` | |||
### Switch | |||
From now the Switch will depend on a fully setup `PeerTransport` to | |||
retrieve/reach out to its peers. As the more low-level concerns are pushed to | |||
the transport, we can omit passing the `config.P2PConfig` to the Switch. | |||
``` go | |||
func NewSwitch(transport PeerTransport, opts ...SwitchOption) *Switch | |||
``` | |||
## Status | |||
In Review. | |||
## Consequences | |||
### Positive | |||
* free Switch from transport concerns - simpler implementation | |||
* pluggable transport implementation - simpler test setup | |||
* remove Switch dependency on P2PConfig - easier to test | |||
### Negative | |||
* more setup for tests which depend on Switches | |||
### Neutral | |||
* multiplexed will be the default implementation | |||
[0] These guards could be potentially extended to be pluggable much like | |||
middlewares to express different concerns required by differentally configured | |||
environments. |
@ -0,0 +1,80 @@ | |||
# ADR 015: Crypto encoding | |||
## Context | |||
We must standardize our method for encoding public keys and signatures on chain. | |||
Currently we amino encode the public keys and signatures. | |||
The reason we are using amino here is primarily due to ease of support in | |||
parsing for other languages. | |||
We don't need its upgradability properties in cryptosystems, as a change in | |||
the crypto that requires adapting the encoding, likely warrants being deemed | |||
a new cryptosystem. | |||
(I.e. using new public parameters) | |||
## Decision | |||
### Public keys | |||
For public keys, we will continue to use amino encoding on the canonical | |||
representation of the pubkey. | |||
(Canonical as defined by the cryptosystem itself) | |||
This has two significant drawbacks. | |||
Amino encoding is less space-efficient, due to requiring support for upgradability. | |||
Amino encoding support requires forking protobuf and adding this new interface support | |||
option in the langauge of choice. | |||
The reason for continuing to use amino however is that people can create code | |||
more easily in languages that already have an up to date amino library. | |||
It is possible that this will change in the future, if it is deemed that | |||
requiring amino for interacting with tendermint cryptography is unneccessary. | |||
The arguments for space efficiency here are refuted on the basis that there are | |||
far more egregious wastages of space in the SDK. | |||
The space requirement of the public keys doesn't cause many problems beyond | |||
increasing the space attached to each validator / account. | |||
The alternative to using amino here would be for us to create an enum type. | |||
Switching to just an enum type is worthy of investigation post-launch. | |||
For referrence, part of amino encoding interfaces is basically a 4 byte enum | |||
type definition. | |||
Enum types would just change that 4 bytes to be a varuint, and it would remove | |||
the protobuf overhead, but it would be hard to integrate into the existing API. | |||
### Signatures | |||
Signatures should be switched to be `[]byte`. | |||
Spatial efficiency in the signatures is quite important, | |||
as it directly affects the gas cost of every transaction, | |||
and the throughput of the chain. | |||
Signatures don't need to encode what type they are for (unlike public keys) | |||
since public keys must already be known. | |||
Therefore we can validate the signature without needing to encode its type. | |||
When placed in state, signatures will still be amino encoded, but it will be the | |||
primitive type `[]byte` getting encoded. | |||
#### Ed25519 | |||
Use the canonical representation for signatures. | |||
#### Secp256k1 | |||
There isn't a clear canonical representation here. | |||
Signatures have two elements `r,s`. | |||
We should encode these bytes as `r || s`, where `r` and `s` are both exactly | |||
32 bytes long. | |||
This is basically Ethereum's encoding, but without the leading recovery bit. | |||
## Status | |||
Proposed. The signature section seems to be agreed upon for the most part. | |||
Needs decision on Enum types. | |||
## Consequences | |||
### Positive | |||
* More space efficient signatures | |||
### Negative | |||
* We have an amino dependency for cryptography. | |||
### Neutral | |||
* No change to public keys |
@ -0,0 +1,128 @@ | |||
package common | |||
import ( | |||
fmt "fmt" | |||
"io" | |||
"os" | |||
"path/filepath" | |||
"strconv" | |||
"strings" | |||
"sync" | |||
"time" | |||
) | |||
const ( | |||
atomicWriteFilePrefix = "write-file-atomic-" | |||
// Maximum number of atomic write file conflicts before we start reseeding | |||
// (reduced from golang's default 10 due to using an increased randomness space) | |||
atomicWriteFileMaxNumConflicts = 5 | |||
// Maximum number of attempts to make at writing the write file before giving up | |||
// (reduced from golang's default 10000 due to using an increased randomness space) | |||
atomicWriteFileMaxNumWriteAttempts = 1000 | |||
// LCG constants from Donald Knuth MMIX | |||
// This LCG's has a period equal to 2**64 | |||
lcgA = 6364136223846793005 | |||
lcgC = 1442695040888963407 | |||
// Create in case it doesn't exist and force kernel | |||
// flush, which still leaves the potential of lingering disk cache. | |||
// Never overwrites files | |||
atomicWriteFileFlag = os.O_WRONLY | os.O_CREATE | os.O_SYNC | os.O_TRUNC | os.O_EXCL | |||
) | |||
var ( | |||
atomicWriteFileRand uint64 | |||
atomicWriteFileRandMu sync.Mutex | |||
) | |||
func writeFileRandReseed() uint64 { | |||
// Scale the PID, to minimize the chance that two processes seeded at similar times | |||
// don't get the same seed. Note that PID typically ranges in [0, 2**15), but can be | |||
// up to 2**22 under certain configurations. We left bit-shift the PID by 20, so that | |||
// a PID difference of one corresponds to a time difference of 2048 seconds. | |||
// The important thing here is that now for a seed conflict, they would both have to be on | |||
// the correct nanosecond offset, and second-based offset, which is much less likely than | |||
// just a conflict with the correct nanosecond offset. | |||
return uint64(time.Now().UnixNano() + int64(os.Getpid()<<20)) | |||
} | |||
// Use a fast thread safe LCG for atomic write file names. | |||
// Returns a string corresponding to a 64 bit int. | |||
// If it was a negative int, the leading number is a 0. | |||
func randWriteFileSuffix() string { | |||
atomicWriteFileRandMu.Lock() | |||
r := atomicWriteFileRand | |||
if r == 0 { | |||
r = writeFileRandReseed() | |||
} | |||
// Update randomness according to lcg | |||
r = r*lcgA + lcgC | |||
atomicWriteFileRand = r | |||
atomicWriteFileRandMu.Unlock() | |||
// Can have a negative name, replace this in the following | |||
suffix := strconv.Itoa(int(r)) | |||
if string(suffix[0]) == "-" { | |||
// Replace first "-" with "0". This is purely for UI clarity, | |||
// as otherwhise there would be two `-` in a row. | |||
suffix = strings.Replace(suffix, "-", "0", 1) | |||
} | |||
return suffix | |||
} | |||
// WriteFileAtomic creates a temporary file with data and provided perm and | |||
// swaps it atomically with filename if successful. | |||
func WriteFileAtomic(filename string, data []byte, perm os.FileMode) (err error) { | |||
// This implementation is inspired by the golang stdlibs method of creating | |||
// tempfiles. Notable differences are that we use different flags, a 64 bit LCG | |||
// and handle negatives differently. | |||
// The core reason we can't use golang's TempFile is that we must write | |||
// to the file synchronously, as we need this to persist to disk. | |||
// We also open it in write-only mode, to avoid concerns that arise with read. | |||
var ( | |||
dir = filepath.Dir(filename) | |||
f *os.File | |||
) | |||
nconflict := 0 | |||
// Limit the number of attempts to create a file. Something is seriously | |||
// wrong if it didn't get created after 1000 attempts, and we don't want | |||
// an infinite loop | |||
i := 0 | |||
for ; i < atomicWriteFileMaxNumWriteAttempts; i++ { | |||
name := filepath.Join(dir, atomicWriteFilePrefix+randWriteFileSuffix()) | |||
f, err = os.OpenFile(name, atomicWriteFileFlag, perm) | |||
// If the file already exists, try a new file | |||
if os.IsExist(err) { | |||
// If the files exists too many times, start reseeding as we've | |||
// likely hit another instances seed. | |||
if nconflict++; nconflict > atomicWriteFileMaxNumConflicts { | |||
atomicWriteFileRandMu.Lock() | |||
atomicWriteFileRand = writeFileRandReseed() | |||
atomicWriteFileRandMu.Unlock() | |||
} | |||
continue | |||
} else if err != nil { | |||
return err | |||
} | |||
break | |||
} | |||
if i == atomicWriteFileMaxNumWriteAttempts { | |||
return fmt.Errorf("Could not create atomic write file after %d attempts", i) | |||
} | |||
// Clean up in any case. Defer stacking order is last-in-first-out. | |||
defer os.Remove(f.Name()) | |||
defer f.Close() | |||
if n, err := f.Write(data); err != nil { | |||
return err | |||
} else if n < len(data) { | |||
return io.ErrShortWrite | |||
} | |||
// Close the file before renaming it, otherwise it will cause "The process | |||
// cannot access the file because it is being used by another process." on windows. | |||
f.Close() | |||
return os.Rename(f.Name(), filename) | |||
} |
@ -0,0 +1,138 @@ | |||
package common | |||
// Need access to internal variables, so can't use _test package | |||
import ( | |||
"bytes" | |||
fmt "fmt" | |||
"io/ioutil" | |||
"os" | |||
testing "testing" | |||
"github.com/stretchr/testify/require" | |||
) | |||
func TestWriteFileAtomic(t *testing.T) { | |||
var ( | |||
data = []byte(RandStr(RandIntn(2048))) | |||
old = RandBytes(RandIntn(2048)) | |||
perm os.FileMode = 0600 | |||
) | |||
f, err := ioutil.TempFile("/tmp", "write-atomic-test-") | |||
if err != nil { | |||
t.Fatal(err) | |||
} | |||
defer os.Remove(f.Name()) | |||
if err = ioutil.WriteFile(f.Name(), old, 0664); err != nil { | |||
t.Fatal(err) | |||
} | |||
if err = WriteFileAtomic(f.Name(), data, perm); err != nil { | |||
t.Fatal(err) | |||
} | |||
rData, err := ioutil.ReadFile(f.Name()) | |||
if err != nil { | |||
t.Fatal(err) | |||
} | |||
if !bytes.Equal(data, rData) { | |||
t.Fatalf("data mismatch: %v != %v", data, rData) | |||
} | |||
stat, err := os.Stat(f.Name()) | |||
if err != nil { | |||
t.Fatal(err) | |||
} | |||
if have, want := stat.Mode().Perm(), perm; have != want { | |||
t.Errorf("have %v, want %v", have, want) | |||
} | |||
} | |||
// This tests atomic write file when there is a single duplicate file. | |||
// Expected behavior is for a new file to be created, and the original write file to be unaltered. | |||
func TestWriteFileAtomicDuplicateFile(t *testing.T) { | |||
var ( | |||
defaultSeed uint64 = 1 | |||
testString = "This is a glorious test string" | |||
expectedString = "Did the test file's string appear here?" | |||
fileToWrite = "/tmp/TestWriteFileAtomicDuplicateFile-test.txt" | |||
) | |||
// Create a file at the seed, and reset the seed. | |||
atomicWriteFileRand = defaultSeed | |||
firstFileRand := randWriteFileSuffix() | |||
atomicWriteFileRand = defaultSeed | |||
fname := "/tmp/" + atomicWriteFilePrefix + firstFileRand | |||
f, err := os.OpenFile(fname, atomicWriteFileFlag, 0777) | |||
defer os.Remove(fname) | |||
// Defer here, in case there is a panic in WriteFileAtomic. | |||
defer os.Remove(fileToWrite) | |||
require.Nil(t, err) | |||
f.WriteString(testString) | |||
WriteFileAtomic(fileToWrite, []byte(expectedString), 0777) | |||
// Check that the first atomic file was untouched | |||
firstAtomicFileBytes, err := ioutil.ReadFile(fname) | |||
require.Nil(t, err, "Error reading first atomic file") | |||
require.Equal(t, []byte(testString), firstAtomicFileBytes, "First atomic file was overwritten") | |||
// Check that the resultant file is correct | |||
resultantFileBytes, err := ioutil.ReadFile(fileToWrite) | |||
require.Nil(t, err, "Error reading resultant file") | |||
require.Equal(t, []byte(expectedString), resultantFileBytes, "Written file had incorrect bytes") | |||
// Check that the intermediate write file was deleted | |||
// Get the second write files' randomness | |||
atomicWriteFileRand = defaultSeed | |||
_ = randWriteFileSuffix() | |||
secondFileRand := randWriteFileSuffix() | |||
_, err = os.Stat("/tmp/" + atomicWriteFilePrefix + secondFileRand) | |||
require.True(t, os.IsNotExist(err), "Intermittent atomic write file not deleted") | |||
} | |||
// This tests atomic write file when there are many duplicate files. | |||
// Expected behavior is for a new file to be created under a completely new seed, | |||
// and the original write files to be unaltered. | |||
func TestWriteFileAtomicManyDuplicates(t *testing.T) { | |||
var ( | |||
defaultSeed uint64 = 2 | |||
testString = "This is a glorious test string, from file %d" | |||
expectedString = "Did any of the test file's string appear here?" | |||
fileToWrite = "/tmp/TestWriteFileAtomicDuplicateFile-test.txt" | |||
) | |||
// Initialize all of the atomic write files | |||
atomicWriteFileRand = defaultSeed | |||
for i := 0; i < atomicWriteFileMaxNumConflicts+2; i++ { | |||
fileRand := randWriteFileSuffix() | |||
fname := "/tmp/" + atomicWriteFilePrefix + fileRand | |||
f, err := os.OpenFile(fname, atomicWriteFileFlag, 0777) | |||
require.Nil(t, err) | |||
f.WriteString(fmt.Sprintf(testString, i)) | |||
defer os.Remove(fname) | |||
} | |||
atomicWriteFileRand = defaultSeed | |||
// Defer here, in case there is a panic in WriteFileAtomic. | |||
defer os.Remove(fileToWrite) | |||
WriteFileAtomic(fileToWrite, []byte(expectedString), 0777) | |||
// Check that all intermittent atomic file were untouched | |||
atomicWriteFileRand = defaultSeed | |||
for i := 0; i < atomicWriteFileMaxNumConflicts+2; i++ { | |||
fileRand := randWriteFileSuffix() | |||
fname := "/tmp/" + atomicWriteFilePrefix + fileRand | |||
firstAtomicFileBytes, err := ioutil.ReadFile(fname) | |||
require.Nil(t, err, "Error reading first atomic file") | |||
require.Equal(t, []byte(fmt.Sprintf(testString, i)), firstAtomicFileBytes, | |||
"atomic write file %d was overwritten", i) | |||
} | |||
// Check that the resultant file is correct | |||
resultantFileBytes, err := ioutil.ReadFile(fileToWrite) | |||
require.Nil(t, err, "Error reading resultant file") | |||
require.Equal(t, []byte(expectedString), resultantFileBytes, "Written file had incorrect bytes") | |||
} |
@ -0,0 +1,32 @@ | |||
9fe4a5a73df12dbd8659b1d9280873fe993caefec6b0ebc2686dd65027148e03,true,80a83ad6afcb6f8175192e41973aed31dd75e3c106f813d986d9567a4865eb2f,96362a04f628a0666d9866147326898bb0847b8db8680263ad19e6336d4eed9e,2632c3fd20f456c5383ed16aa1d56dc7875a2b0fc0d5ff053c3ada8934098c69 | |||
0716764b370d543fee692af03832c16410f0a56e4ddb79604ea093b10bb6f654,false,84f2b1e8658456529a2c324f46c3406c3c6fecd5fbbf9169f60bed8956a8b03d,cba357ae33d7234520d5742102a2a6cdb39b7db59c14a58fa8aadd310127630f,576643a8fcc1a4cf866db900f4a150dbe35d44a1b3ff36e4911565c3fa22fc32 | |||
358dd73aae2c5b7b94b57f950408a3c681e748777ecab2063c8ca51a63588fa8,false,c2e2f664c8ee561af8e1e30553373be4ae23edecc8c6bd762d44b2afb7f2a037,d1563f428ac1c023c15d8082b2503157fe9ecbde4fb3493edd69ebc299b4970c,89fb6c6439b12fe11a4c604b8ad883f7dc76be33df590818fe5eb15ddb01face | |||
0958308bdb583e639dd399a98cd21077d834b4b5e30771275a5a73a62efcc7e0,false,523c0ae97039173566f7ab4b8f271d8d78feef5a432d618e58ced4f80f7c1696,c1b743401c6e4508e62b8245ea7c3252bbad082e10af10e80608084d63877977,d7c52adf12ebc69677aec4bd387b0c5a35570fe61cb7b8ae55f3ab14b1b79be0 | |||
d93d134e72f58f177642ac30f36b2d3cd4720aa7e60feb1296411a9009cf4524,false,47a427bcc1ef6f0ce31dbf343bc8bbf49554b4dd1e2330fd97d0df23ecdbba10,73e23adb7801179349ecf9c8cdf64d71d64a9f1145ba6730e5d029f99eaf8840,a8fdcb77f591bfba7b8483aa15ae7b42054ba68625d51dec005896dfe910281f | |||
6104474c791cda24d952b356fb41a5d273c0ce6cc87d270b1701d0523cd5aa13,true,1cb4397b9e478430321af4647da2ccbef62ff8888542d31cca3f626766c8080f,673b23318826bd31ad1a4995c6e5095c4b092f5598aa0a96381a3e977bc0eaf9,4a25a25c5f75d6cc512f2ba8c1546e6263e9ef8269f0c046c37838cc66aa83e6 | |||
8a6002503c15cab763e27c53fc449f6854a210c95cdd67e4466b0f2cb46b629c,false,f01ff06aef356c87f8d2646ff9ed8b855497c2ca00ea330661d84ef421a67e63,4f59bb23090010614877265a1597f1a142fa97b7208e1d554435763505f36f6a,1aadcb1c8b5993da102cebcb60c545b03197c98137064530840f45d917ad300e | |||
31a57c6b1fe33beb1f7ebbbfc06d58c4f307cd355b6f9753e58f3edec16c7559,false,13e126c4cb240349dccf0dc843977671d34a1daffd0517d06ed66b703344db22,d491431906a306af45ecf9f1977e32d7f65a79f5139f931760416de27554b687,5ea7e8e3d5a30503423341609d360d246b61a9159fc07f253a46e357977cd745 | |||
71a3c79718b824627faeefdce887d9465b353bd962cc5e97c5b5dfedab457ef9,true,e2e8eea547dcee7eafa89ae41f48ab049beac24935fad75258924fd5273d23cb,45d2e839bf36a3616cbe8a9bdbd4e7b288bf5bf1e6e79c07995eb2b18eb2eaff,7ee50e0810bc9f98e56bc46de5da22d84b3efa52fe5d85db4b2344530ef17ed8 | |||
2e9dba2eb4f9019c2628ff5899744469c26caf793636f30ddb76601751aee968,false,8bfc3b314e4468d4e19c9d28b7bfd5b5532263105273b0fe80801f6146313993,b77d2b223e27038f978ab87a725859f6995f903056bdbd594ab04f0b2cbad517,9032be49a9cbcd1de6fee332f8f24ebf545c05e0175b98c564e7d1e69630ae20 | |||
81322b22c835efb26d78051f3a3840a9d01aa558c019ecfa26483b5c5535728c,true,61eacb7e9665e362ef492ef950cea58f8bc67434ab7ee5545139147adf395da4,0f600ef0c358cae938969f434c2ec0ce3be632fdf5246b7bb8ee3ff294036ecd,a7026b4c21fe225ecd775ae81249405c6f492882eb85f3f8e2232f11e515561e | |||
826b86c5e8cb4173ff2d05c48e3537140c5e0f26f7866bbcd4e57616806e1be2,true,ae44dabd077d227c8d898930a7705a2b785c8849121282106c045bb58b66eb36,24b2c1b1e2a9ebe387df6dfb9fbde6c681e4eeb0a33bb1c3df3789087f56ffe3,b37a64ea97431b25cb271c4c8435f6dd97118b35da57168f3c3c269920f7bbc1 | |||
18b5a7b973d4b263072e69515c5b6ed22191c3d6e851aaba872904672f8344ec,true,ce402af2fb93b6ef18cd406f7c437d3cbfb09141b7a02116b1cfbabbf75ad84a,c86bdb1709ef0f4a31a818843660f83338b9db77e262bb7c6546138e51c6046b,11fcd8e59c4e7f6050d3cd332337db794ae31260c159e409af3ed8f4d6523bf4 | |||
26d10c56872b72bb76ae7c7b3f074afb3d4a364e5e3f8c661be9b4f5a522ea75,true,1c9782a8485c4ecb13904ec551a7f9300ecd687abfbe63c91c7fd583f84a7a4d,ae3f4ccd0dfee8b514f67db2e923714d324935b9ae9e488d088ebb79569d8cc4,8139a3ab728b0e765e4d90549ab8eed7e1048a83267eafa7442208a7f627558a | |||
558838dfcfe94105c46a4ade4548e6c96271d33e6c752661356cc66024615bae,true,d5a38625be74177318072cf877f2427ce2327e9b58d2eb134d0ac52c9126572f,dead938f77007e3164b6eee4cd153433d03ca5d9ec64f41aa6b2d6a069edeeda,4a081a356361da429c564cf7ac8e217121bbe8c5ee5c9632bae0b7ddbe94f9d4 | |||
f4a3f6a93a4827a59682fd8bf1a8e4fd9aaff01a337a86e1966c8fff0e746014,true,39a0aea2a8ac7f0524d63e395a25b98fc3844ed039f20b11058019dca2b3840f,6ff53243426ded506d22501ae0f989d9946b86a8bb2550d7ed6e90fdf41d0e7c,8784e728bf12f465ed20dc6f0e1d949a68e5795d4799536427a6f859547b7fd6 | |||
1717020e1c4fca1b4926dba16671c0c04e4f19c621c646cb4525fa533b1c205c,false,b9a909767f3044608b4e314b149a729bef199f8311310e1ecd2072e5659b7194,7baf0ff4b980919cf545312f45234976f0b6c574aac5b772024f73248aad7538,99a18e1e4b039ef3777a8fdd0d9ffaccaf3b4523b6d26adacfe91cc5fcd9977e | |||
de769062be27b2a4248dd5be315960c8d231738417ece670c2d6a1c52877b59e,true,cc6c2086718b21813513894546e85766d34c754e81fd6a19c12fc322ffb9b1c3,5a7da7500191c65a5f1fbb2a6122717edc70ca0469baf2bbbd6ca8255b93c077,8c0d32091dc687f1399c754a617d224742726bece848b50c35b4db5f0469ace7 | |||
7c5549f36767e02ebf49a4616467199459aa6932dcc091f182f822185659559a,true,d8335e606128b0c621ff6cda99dc62babf4a4436c574c5c478c20122712727d0,0a7c673cccd6f7fd4ed1673f7d0f2cb08961faced123ca901b74581d5bdc8b25,16ac1eb2a39384716c7d490272d87e76c10665fdb331e1883435de175ce4460e | |||
ecf8261ebda248dc7796f98987efe1b7be363a59037c9e61044490d08a077610,true,53def80fcdba01367c0ea36459b57409f59a771f57a8259b54f24785e5656b7d,90140870b3b1e84c9dcf7836eac0581b16fe0a40307619d267c6f871e1efce6a,c6d1836b66c1a722a377c7eb058995a0ef8711839c6d6a0cdd6ad1ff70f935a5 | |||
21c0ef76ce0eae9391ceabfb08a861899db55ac4ccf010ed672599669c6938f2,false,8af5482cc015093f261d5b7ce87035dda41d8318b9960b52cca3e5f0d3f61808,f4d5338bcb57262e1034f01ed3858ca1e5d66a73f18588e72f3dc8c6a730be0c,7ba82c2820c95e3354d9a6ab4920ebcd7938ce19e25930fee58439246b0321b1 | |||
05f3b66d6b0fe906137e60b4719083a2465106badedcdae3a4c91c46c5367340,false,e5c9e074e95c2896fa4093830e96e9cf159b8dcba2ead21f37237cf6e9a9aaa2,b3a0a50309b4ca23cd34363fd8df30e73ec4a275973986c2e11a53752eff0a3b,358a62056ff05f27185b9952d291c6346171937f6811cafbacddd82e17010f39 | |||
fef0251cff7c5d1ba0514f1820a8265453365fd9f5bb8a92f955dc007a40e730,true,e35a0aff6e9060a39c15d276a1337f1948d0be0aef81fcd563a6783115b5283d,20a8efe83474253d70e5fd847df0cd26222cd39e9210687b68c0a23b73429108,2989fab4278b32f4f40dc02227ab30e10f62e15ab7aa7382da769b1d084e33df | |||
1b7bb172baa2753ec9c3e81a7a9b4c6ef10f9ed7afcafa975395f095eca63a54,false,a98257203987d0c4d260d8feef841466977276612e268b69b5ce4191af161b29,ea177a20d6c1f73f9667090568f9197943037d6586f7e2d6b7b81756fc71df5f,844eff318ef4c6ee45f158c1946ff999e40ffac70883ab6d6b90995f246e69a2 | |||
5ee9b60a25753066d0ecc1155ca6afcc6b853ba558c9533c134a93b82e756856,true,9889460b95ca9545864a4a5194891b7d475362428d6d797532da10bf1fc92076,a7a96739abd8eceb6751afc98df68e29f7af16fbfda3d4710df9c35b6dcdb4d5,998326285c90a2ea2e1f6c6dac79530742645e3dd1b2b42a0733388a99cab81b | |||
a102613781872f88a949d82cb5efcc2e0f437010a950d71b87929ecb480af3b3,false,e099080a55b9b29ccecbbb0d91dbe49defcc217efd1de0588e0836ce5970d327,319293b8660a3cea9879487645ddadda72a5c60079c9154bb0dbb8a0c9cda79e,4d567f1b1a1b304347cf7b129e4c7a05aa57e2bbb8ea335db9e33d05fab12e4d | |||
1d4538180d06f37c43e8caa2d0d80aa7c5d701c8c3e31508704131427837f5cc,true,73afeeb46efc03d2b9f20fc271752528e52b8931287296a7e4367c96bccb32bd,59dc4b69d9ccf6f77715e47fb9bf454f1b90bbd05f1d2bbd07c7d6666f31c91f,ac59d735dfcdc3a0a4ce5a10f09dea8c6afd47de9c0308dc817e3789c8aee963 | |||
e4c480af1b0e3487a331761f64eb3f020a2b8ffa25ad17e00f57aa7ec2c5e84d,true,1145e9f001c70d364e97fcdbc88a2a3d6aecdd975212923820f90a0b215f11f6,b802ac7ef21c8abaeae024c76e3fa70a2a82f73e0bb7c7fe76752ad1742af2e6,0a95876e30617e32ae25acd3af97c37dc075825f800def3f2bf3f68a268744e9 | |||
3a7a83dd657dd6277bcfa957534f40d9b559039aad752066a8d7ed9a6d9c0ab5,false,f90a251ad2338b19cfee6a7965f6f5098136974abb99b3d24553fa6117384978,e422ed7567e5602731b3d980106d0546ef4a4da5eb7175d66a452df12d37bad2,b086bed71dfb6662cb10e2b4fb16a7c22394f488e822fc19697db6077f6caf6f | |||
273e8560c2b1734e863a6542bded7a6fcbfb49a12770bd8866d4863dceea3ae9,false,3b7849a362e7b7ba8c8b8a0cd00df5180604987dbda6c03f37d9a09fdb27fb28,e6cdf4d767df0f411e970da8dda6acd3c2c34ce63908d8a6dbf3715daa0318e4,359a4a39fbdffc808161a48a3ffbe77fc6a03ff52324c22510a42e46c08a6f22 | |||
9b4f8702991be9569b6c0b07a2173104d41325017b27d68fa5af91cdab164c4d,true,598323677db11ece050289f31881ee8caacb59376c7182f9055708b2a4673f84,7675adc1264b6758beb097a991f766f62796f78c1cfa58a4de3d81c36434d3ae,d5d8d610ffd85b04cbe1c73ff5becd5917c513d9625b001f51d486d0dadcefe3 | |||
e1a686ba0169eb97379ebf9d22e073819450ee5ad5f049c8e93016e8d2ec1430,false,ffe461e6075865cde2704aa148fd29bcf0af245803f446cb6153244f25617993,46df6c25fa0344e662490c4da0bddca626644e67e66705840ef08aae35c343fa,e9a56d75acad4272ab0c49ee5919a4e86e6c5695ef065704c1e592d4e7b41a10 |
@ -0,0 +1,58 @@ | |||
package core | |||
import ( | |||
"fmt" | |||
"testing" | |||
"github.com/stretchr/testify/require" | |||
) | |||
func TestBlockchainInfo(t *testing.T) { | |||
cases := []struct { | |||
min, max int64 | |||
height int64 | |||
limit int64 | |||
resultLength int64 | |||
wantErr bool | |||
}{ | |||
// min > max | |||
{0, 0, 0, 10, 0, true}, // min set to 1 | |||
{0, 1, 0, 10, 0, true}, // max set to height (0) | |||
{0, 0, 1, 10, 1, false}, // max set to height (1) | |||
{2, 0, 1, 10, 0, true}, // max set to height (1) | |||
{2, 1, 5, 10, 0, true}, | |||
// negative | |||
{1, 10, 14, 10, 10, false}, // control | |||
{-1, 10, 14, 10, 0, true}, | |||
{1, -10, 14, 10, 0, true}, | |||
{-9223372036854775808, -9223372036854775788, 100, 20, 0, true}, | |||
// check limit and height | |||
{1, 1, 1, 10, 1, false}, | |||
{1, 1, 5, 10, 1, false}, | |||
{2, 2, 5, 10, 1, false}, | |||
{1, 2, 5, 10, 2, false}, | |||
{1, 5, 1, 10, 1, false}, | |||
{1, 5, 10, 10, 5, false}, | |||
{1, 15, 10, 10, 10, false}, | |||
{1, 15, 15, 10, 10, false}, | |||
{1, 15, 15, 20, 15, false}, | |||
{1, 20, 15, 20, 15, false}, | |||
{1, 20, 20, 20, 20, false}, | |||
} | |||
for i, c := range cases { | |||
caseString := fmt.Sprintf("test %d failed", i) | |||
min, max, err := filterMinMax(c.height, c.min, c.max, c.limit) | |||
if c.wantErr { | |||
require.Error(t, err, caseString) | |||
} else { | |||
require.NoError(t, err, caseString) | |||
require.Equal(t, 1+max-min, c.resultLength, caseString) | |||
} | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
--- | |||
title: RPC Reference | |||
language_tabs: # must be one of https://git.io/vQNgJ | |||
- shell | |||
- go | |||
toc_footers: | |||
- <a href='https://tendermint.com/'>Tendermint</a> | |||
- <a href='https://github.com/lord/slate'>Documentation Powered by Slate</a> | |||
search: true | |||
--- |
@ -1,39 +0,0 @@ | |||
package core | |||
import ( | |||
"testing" | |||
"time" | |||
"github.com/tendermint/tendermint/types" | |||
) | |||
func TestGetValidatorsWithTimeout(t *testing.T) { | |||
height, vs := getValidatorsWithTimeout( | |||
testValidatorReceiver{}, | |||
time.Millisecond, | |||
) | |||
if height != -1 { | |||
t.Errorf("expected negative height") | |||
} | |||
if len(vs) != 0 { | |||
t.Errorf("expected no validators") | |||
} | |||
} | |||
type testValidatorReceiver struct{} | |||
func (tr testValidatorReceiver) GetValidators() (int64, []*types.Validator) { | |||
vs := []*types.Validator{} | |||
for i := 0; i < 3; i++ { | |||
v, _ := types.RandValidator(true, 10) | |||
vs = append(vs, v) | |||
} | |||
time.Sleep(time.Millisecond) | |||
return 10, vs | |||
} |
@ -1,204 +0,0 @@ | |||
Tendermint Core | |||
License: Apache2.0 | |||
Apache License | |||
Version 2.0, January 2004 | |||
http://www.apache.org/licenses/ | |||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | |||
1. Definitions. | |||
"License" shall mean the terms and conditions for use, reproduction, | |||
and distribution as defined by Sections 1 through 9 of this document. | |||
"Licensor" shall mean the copyright owner or entity authorized by | |||
the copyright owner that is granting the License. | |||
"Legal Entity" shall mean the union of the acting entity and all | |||
other entities that control, are controlled by, or are under common | |||
control with that entity. For the purposes of this definition, | |||
"control" means (i) the power, direct or indirect, to cause the | |||
direction or management of such entity, whether by contract or | |||
otherwise, or (ii) ownership of fifty percent (50%) or more of the | |||
outstanding shares, or (iii) beneficial ownership of such entity. | |||
"You" (or "Your") shall mean an individual or Legal Entity | |||
exercising permissions granted by this License. | |||
"Source" form shall mean the preferred form for making modifications, | |||
including but not limited to software source code, documentation | |||
source, and configuration files. | |||
"Object" form shall mean any form resulting from mechanical | |||
transformation or translation of a Source form, including but | |||
not limited to compiled object code, generated documentation, | |||
and conversions to other media types. | |||
"Work" shall mean the work of authorship, whether in Source or | |||
Object form, made available under the License, as indicated by a | |||
copyright notice that is included in or attached to the work | |||
(an example is provided in the Appendix below). | |||
"Derivative Works" shall mean any work, whether in Source or Object | |||
form, that is based on (or derived from) the Work and for which the | |||
editorial revisions, annotations, elaborations, or other modifications | |||
represent, as a whole, an original work of authorship. For the purposes | |||
of this License, Derivative Works shall not include works that remain | |||
separable from, or merely link (or bind by name) to the interfaces of, | |||
the Work and Derivative Works thereof. | |||
"Contribution" shall mean any work of authorship, including | |||
the original version of the Work and any modifications or additions | |||
to that Work or Derivative Works thereof, that is intentionally | |||
submitted to Licensor for inclusion in the Work by the copyright owner | |||
or by an individual or Legal Entity authorized to submit on behalf of | |||
the copyright owner. For the purposes of this definition, "submitted" | |||
means any form of electronic, verbal, or written communication sent | |||
to the Licensor or its representatives, including but not limited to | |||
communication on electronic mailing lists, source code control systems, | |||
and issue tracking systems that are managed by, or on behalf of, the | |||
Licensor for the purpose of discussing and improving the Work, but | |||
excluding communication that is conspicuously marked or otherwise | |||
designated in writing by the copyright owner as "Not a Contribution." | |||
"Contributor" shall mean Licensor and any individual or Legal Entity | |||
on behalf of whom a Contribution has been received by Licensor and | |||
subsequently incorporated within the Work. | |||
2. Grant of Copyright License. Subject to the terms and conditions of | |||
this License, each Contributor hereby grants to You a perpetual, | |||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |||
copyright license to reproduce, prepare Derivative Works of, | |||
publicly display, publicly perform, sublicense, and distribute the | |||
Work and such Derivative Works in Source or Object form. | |||
3. Grant of Patent License. Subject to the terms and conditions of | |||
this License, each Contributor hereby grants to You a perpetual, | |||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |||
(except as stated in this section) patent license to make, have made, | |||
use, offer to sell, sell, import, and otherwise transfer the Work, | |||
where such license applies only to those patent claims licensable | |||
by such Contributor that are necessarily infringed by their | |||
Contribution(s) alone or by combination of their Contribution(s) | |||
with the Work to which such Contribution(s) was submitted. If You | |||
institute patent litigation against any entity (including a | |||
cross-claim or counterclaim in a lawsuit) alleging that the Work | |||
or a Contribution incorporated within the Work constitutes direct | |||
or contributory patent infringement, then any patent licenses | |||
granted to You under this License for that Work shall terminate | |||
as of the date such litigation is filed. | |||
4. Redistribution. You may reproduce and distribute copies of the | |||
Work or Derivative Works thereof in any medium, with or without | |||
modifications, and in Source or Object form, provided that You | |||
meet the following conditions: | |||
(a) You must give any other recipients of the Work or | |||
Derivative Works a copy of this License; and | |||
(b) You must cause any modified files to carry prominent notices | |||
stating that You changed the files; and | |||
(c) You must retain, in the Source form of any Derivative Works | |||
that You distribute, all copyright, patent, trademark, and | |||
attribution notices from the Source form of the Work, | |||
excluding those notices that do not pertain to any part of | |||
the Derivative Works; and | |||
(d) If the Work includes a "NOTICE" text file as part of its | |||
distribution, then any Derivative Works that You distribute must | |||
include a readable copy of the attribution notices contained | |||
within such NOTICE file, excluding those notices that do not | |||
pertain to any part of the Derivative Works, in at least one | |||
of the following places: within a NOTICE text file distributed | |||
as part of the Derivative Works; within the Source form or | |||
documentation, if provided along with the Derivative Works; or, | |||
within a display generated by the Derivative Works, if and | |||
wherever such third-party notices normally appear. The contents | |||
of the NOTICE file are for informational purposes only and | |||
do not modify the License. You may add Your own attribution | |||
notices within Derivative Works that You distribute, alongside | |||
or as an addendum to the NOTICE text from the Work, provided | |||
that such additional attribution notices cannot be construed | |||
as modifying the License. | |||
You may add Your own copyright statement to Your modifications and | |||
may provide additional or different license terms and conditions | |||
for use, reproduction, or distribution of Your modifications, or | |||
for any such Derivative Works as a whole, provided Your use, | |||
reproduction, and distribution of the Work otherwise complies with | |||
the conditions stated in this License. | |||
5. Submission of Contributions. Unless You explicitly state otherwise, | |||
any Contribution intentionally submitted for inclusion in the Work | |||
by You to the Licensor shall be under the terms and conditions of | |||
this License, without any additional terms or conditions. | |||
Notwithstanding the above, nothing herein shall supersede or modify | |||
the terms of any separate license agreement you may have executed | |||
with Licensor regarding such Contributions. | |||
6. Trademarks. This License does not grant permission to use the trade | |||
names, trademarks, service marks, or product names of the Licensor, | |||
except as required for reasonable and customary use in describing the | |||
origin of the Work and reproducing the content of the NOTICE file. | |||
7. Disclaimer of Warranty. Unless required by applicable law or | |||
agreed to in writing, Licensor provides the Work (and each | |||
Contributor provides its Contributions) on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | |||
implied, including, without limitation, any warranties or conditions | |||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | |||
PARTICULAR PURPOSE. You are solely responsible for determining the | |||
appropriateness of using or redistributing the Work and assume any | |||
risks associated with Your exercise of permissions under this License. | |||
8. Limitation of Liability. In no event and under no legal theory, | |||
whether in tort (including negligence), contract, or otherwise, | |||
unless required by applicable law (such as deliberate and grossly | |||
negligent acts) or agreed to in writing, shall any Contributor be | |||
liable to You for damages, including any direct, indirect, special, | |||
incidental, or consequential damages of any character arising as a | |||
result of this License or out of the use or inability to use the | |||
Work (including but not limited to damages for loss of goodwill, | |||
work stoppage, computer failure or malfunction, or any and all | |||
other commercial damages or losses), even if such Contributor | |||
has been advised of the possibility of such damages. | |||
9. Accepting Warranty or Additional Liability. While redistributing | |||
the Work or Derivative Works thereof, You may choose to offer, | |||
and charge a fee for, acceptance of support, warranty, indemnity, | |||
or other liability obligations and/or rights consistent with this | |||
License. However, in accepting such obligations, You may act only | |||
on Your own behalf and on Your sole responsibility, not on behalf | |||
of any other Contributor, and only if You agree to indemnify, | |||
defend, and hold each Contributor harmless for any liability | |||
incurred by, or claims asserted against, such Contributor by reason | |||
of your accepting any such warranty or additional liability. | |||
END OF TERMS AND CONDITIONS | |||
APPENDIX: How to apply the Apache License to your work. | |||
To apply the Apache License to your work, attach the following | |||
boilerplate notice, with the fields enclosed by brackets "{}" | |||
replaced with your own identifying information. (Don't include | |||
the brackets!) The text should be enclosed in the appropriate | |||
comment syntax for the file format. We also recommend that a | |||
file or class name and description of purpose be included on the | |||
same "printed page" as the copyright notice for easier | |||
identification within third-party archives. | |||
Copyright 2016 All in Bits, Inc | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
You may obtain a copy of the License at | |||
http://www.apache.org/licenses/LICENSE-2.0 | |||
Unless required by applicable law or agreed to in writing, software | |||
distributed under the License is distributed on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
See the License for the specific language governing permissions and | |||
limitations under the License. |
@ -1,192 +0,0 @@ | |||
Copyright (C) 2017 Tendermint | |||
Apache License | |||
Version 2.0, January 2004 | |||
https://www.apache.org/licenses/ | |||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | |||
1. Definitions. | |||
"License" shall mean the terms and conditions for use, reproduction, | |||
and distribution as defined by Sections 1 through 9 of this document. | |||
"Licensor" shall mean the copyright owner or entity authorized by | |||
the copyright owner that is granting the License. | |||
"Legal Entity" shall mean the union of the acting entity and all | |||
other entities that control, are controlled by, or are under common | |||
control with that entity. For the purposes of this definition, | |||
"control" means (i) the power, direct or indirect, to cause the | |||
direction or management of such entity, whether by contract or | |||
otherwise, or (ii) ownership of fifty percent (50%) or more of the | |||
outstanding shares, or (iii) beneficial ownership of such entity. | |||
"You" (or "Your") shall mean an individual or Legal Entity | |||
exercising permissions granted by this License. | |||
"Source" form shall mean the preferred form for making modifications, | |||
including but not limited to software source code, documentation | |||
source, and configuration files. | |||
"Object" form shall mean any form resulting from mechanical | |||
transformation or translation of a Source form, including but | |||
not limited to compiled object code, generated documentation, | |||
and conversions to other media types. | |||
"Work" shall mean the work of authorship, whether in Source or | |||
Object form, made available under the License, as indicated by a | |||
copyright notice that is included in or attached to the work | |||
(an example is provided in the Appendix below). | |||
"Derivative Works" shall mean any work, whether in Source or Object | |||
form, that is based on (or derived from) the Work and for which the | |||
editorial revisions, annotations, elaborations, or other modifications | |||
represent, as a whole, an original work of authorship. For the purposes | |||
of this License, Derivative Works shall not include works that remain | |||
separable from, or merely link (or bind by name) to the interfaces of, | |||
the Work and Derivative Works thereof. | |||
"Contribution" shall mean any work of authorship, including | |||
the original version of the Work and any modifications or additions | |||
to that Work or Derivative Works thereof, that is intentionally | |||
submitted to Licensor for inclusion in the Work by the copyright owner | |||
or by an individual or Legal Entity authorized to submit on behalf of | |||
the copyright owner. For the purposes of this definition, "submitted" | |||
means any form of electronic, verbal, or written communication sent | |||
to the Licensor or its representatives, including but not limited to | |||
communication on electronic mailing lists, source code control systems, | |||
and issue tracking systems that are managed by, or on behalf of, the | |||
Licensor for the purpose of discussing and improving the Work, but | |||
excluding communication that is conspicuously marked or otherwise | |||
designated in writing by the copyright owner as "Not a Contribution." | |||
"Contributor" shall mean Licensor and any individual or Legal Entity | |||
on behalf of whom a Contribution has been received by Licensor and | |||
subsequently incorporated within the Work. | |||
2. Grant of Copyright License. Subject to the terms and conditions of | |||
this License, each Contributor hereby grants to You a perpetual, | |||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |||
copyright license to reproduce, prepare Derivative Works of, | |||
publicly display, publicly perform, sublicense, and distribute the | |||
Work and such Derivative Works in Source or Object form. | |||
3. Grant of Patent License. Subject to the terms and conditions of | |||
this License, each Contributor hereby grants to You a perpetual, | |||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |||
(except as stated in this section) patent license to make, have made, | |||
use, offer to sell, sell, import, and otherwise transfer the Work, | |||
where such license applies only to those patent claims licensable | |||
by such Contributor that are necessarily infringed by their | |||
Contribution(s) alone or by combination of their Contribution(s) | |||
with the Work to which such Contribution(s) was submitted. If You | |||
institute patent litigation against any entity (including a | |||
cross-claim or counterclaim in a lawsuit) alleging that the Work | |||
or a Contribution incorporated within the Work constitutes direct | |||
or contributory patent infringement, then any patent licenses | |||
granted to You under this License for that Work shall terminate | |||
as of the date such litigation is filed. | |||
4. Redistribution. You may reproduce and distribute copies of the | |||
Work or Derivative Works thereof in any medium, with or without | |||
modifications, and in Source or Object form, provided that You | |||
meet the following conditions: | |||
(a) You must give any other recipients of the Work or | |||
Derivative Works a copy of this License; and | |||
(b) You must cause any modified files to carry prominent notices | |||
stating that You changed the files; and | |||
(c) You must retain, in the Source form of any Derivative Works | |||
that You distribute, all copyright, patent, trademark, and | |||
attribution notices from the Source form of the Work, | |||
excluding those notices that do not pertain to any part of | |||
the Derivative Works; and | |||
(d) If the Work includes a "NOTICE" text file as part of its | |||
distribution, then any Derivative Works that You distribute must | |||
include a readable copy of the attribution notices contained | |||
within such NOTICE file, excluding those notices that do not | |||
pertain to any part of the Derivative Works, in at least one | |||
of the following places: within a NOTICE text file distributed | |||
as part of the Derivative Works; within the Source form or | |||
documentation, if provided along with the Derivative Works; or, | |||
within a display generated by the Derivative Works, if and | |||
wherever such third-party notices normally appear. The contents | |||
of the NOTICE file are for informational purposes only and | |||
do not modify the License. You may add Your own attribution | |||
notices within Derivative Works that You distribute, alongside | |||
or as an addendum to the NOTICE text from the Work, provided | |||
that such additional attribution notices cannot be construed | |||
as modifying the License. | |||
You may add Your own copyright statement to Your modifications and | |||
may provide additional or different license terms and conditions | |||
for use, reproduction, or distribution of Your modifications, or | |||
for any such Derivative Works as a whole, provided Your use, | |||
reproduction, and distribution of the Work otherwise complies with | |||
the conditions stated in this License. | |||
5. Submission of Contributions. Unless You explicitly state otherwise, | |||
any Contribution intentionally submitted for inclusion in the Work | |||
by You to the Licensor shall be under the terms and conditions of | |||
this License, without any additional terms or conditions. | |||
Notwithstanding the above, nothing herein shall supersede or modify | |||
the terms of any separate license agreement you may have executed | |||
with Licensor regarding such Contributions. | |||
6. Trademarks. This License does not grant permission to use the trade | |||
names, trademarks, service marks, or product names of the Licensor, | |||
except as required for reasonable and customary use in describing the | |||
origin of the Work and reproducing the content of the NOTICE file. | |||
7. Disclaimer of Warranty. Unless required by applicable law or | |||
agreed to in writing, Licensor provides the Work (and each | |||
Contributor provides its Contributions) on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | |||
implied, including, without limitation, any warranties or conditions | |||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | |||
PARTICULAR PURPOSE. You are solely responsible for determining the | |||
appropriateness of using or redistributing the Work and assume any | |||
risks associated with Your exercise of permissions under this License. | |||
8. Limitation of Liability. In no event and under no legal theory, | |||
whether in tort (including negligence), contract, or otherwise, | |||
unless required by applicable law (such as deliberate and grossly | |||
negligent acts) or agreed to in writing, shall any Contributor be | |||
liable to You for damages, including any direct, indirect, special, | |||
incidental, or consequential damages of any character arising as a | |||
result of this License or out of the use or inability to use the | |||
Work (including but not limited to damages for loss of goodwill, | |||
work stoppage, computer failure or malfunction, or any and all | |||
other commercial damages or losses), even if such Contributor | |||
has been advised of the possibility of such damages. | |||
9. Accepting Warranty or Additional Liability. While redistributing | |||
the Work or Derivative Works thereof, You may choose to offer, | |||
and charge a fee for, acceptance of support, warranty, indemnity, | |||
or other liability obligations and/or rights consistent with this | |||
License. However, in accepting such obligations, You may act only | |||
on Your own behalf and on Your sole responsibility, not on behalf | |||
of any other Contributor, and only if You agree to indemnify, | |||
defend, and hold each Contributor harmless for any liability | |||
incurred by, or claims asserted against, such Contributor by reason | |||
of your accepting any such warranty or additional liability. | |||
END OF TERMS AND CONDITIONS | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
You may obtain a copy of the License at | |||
https://www.apache.org/licenses/LICENSE-2.0 | |||
Unless required by applicable law or agreed to in writing, software | |||
distributed under the License is distributed on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
See the License for the specific language governing permissions and | |||
limitations under the License. |
@ -1,204 +0,0 @@ | |||
Tendermint Bench | |||
Copyright 2017 Tendermint | |||
Apache License | |||
Version 2.0, January 2004 | |||
http://www.apache.org/licenses/ | |||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | |||
1. Definitions. | |||
"License" shall mean the terms and conditions for use, reproduction, | |||
and distribution as defined by Sections 1 through 9 of this document. | |||
"Licensor" shall mean the copyright owner or entity authorized by | |||
the copyright owner that is granting the License. | |||
"Legal Entity" shall mean the union of the acting entity and all | |||
other entities that control, are controlled by, or are under common | |||
control with that entity. For the purposes of this definition, | |||
"control" means (i) the power, direct or indirect, to cause the | |||
direction or management of such entity, whether by contract or | |||
otherwise, or (ii) ownership of fifty percent (50%) or more of the | |||
outstanding shares, or (iii) beneficial ownership of such entity. | |||
"You" (or "Your") shall mean an individual or Legal Entity | |||
exercising permissions granted by this License. | |||
"Source" form shall mean the preferred form for making modifications, | |||
including but not limited to software source code, documentation | |||
source, and configuration files. | |||
"Object" form shall mean any form resulting from mechanical | |||
transformation or translation of a Source form, including but | |||
not limited to compiled object code, generated documentation, | |||
and conversions to other media types. | |||
"Work" shall mean the work of authorship, whether in Source or | |||
Object form, made available under the License, as indicated by a | |||
copyright notice that is included in or attached to the work | |||
(an example is provided in the Appendix below). | |||
"Derivative Works" shall mean any work, whether in Source or Object | |||
form, that is based on (or derived from) the Work and for which the | |||
editorial revisions, annotations, elaborations, or other modifications | |||
represent, as a whole, an original work of authorship. For the purposes | |||
of this License, Derivative Works shall not include works that remain | |||
separable from, or merely link (or bind by name) to the interfaces of, | |||
the Work and Derivative Works thereof. | |||
"Contribution" shall mean any work of authorship, including | |||
the original version of the Work and any modifications or additions | |||
to that Work or Derivative Works thereof, that is intentionally | |||
submitted to Licensor for inclusion in the Work by the copyright owner | |||
or by an individual or Legal Entity authorized to submit on behalf of | |||
the copyright owner. For the purposes of this definition, "submitted" | |||
means any form of electronic, verbal, or written communication sent | |||
to the Licensor or its representatives, including but not limited to | |||
communication on electronic mailing lists, source code control systems, | |||
and issue tracking systems that are managed by, or on behalf of, the | |||
Licensor for the purpose of discussing and improving the Work, but | |||
excluding communication that is conspicuously marked or otherwise | |||
designated in writing by the copyright owner as "Not a Contribution." | |||
"Contributor" shall mean Licensor and any individual or Legal Entity | |||
on behalf of whom a Contribution has been received by Licensor and | |||
subsequently incorporated within the Work. | |||
2. Grant of Copyright License. Subject to the terms and conditions of | |||
this License, each Contributor hereby grants to You a perpetual, | |||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |||
copyright license to reproduce, prepare Derivative Works of, | |||
publicly display, publicly perform, sublicense, and distribute the | |||
Work and such Derivative Works in Source or Object form. | |||
3. Grant of Patent License. Subject to the terms and conditions of | |||
this License, each Contributor hereby grants to You a perpetual, | |||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |||
(except as stated in this section) patent license to make, have made, | |||
use, offer to sell, sell, import, and otherwise transfer the Work, | |||
where such license applies only to those patent claims licensable | |||
by such Contributor that are necessarily infringed by their | |||
Contribution(s) alone or by combination of their Contribution(s) | |||
with the Work to which such Contribution(s) was submitted. If You | |||
institute patent litigation against any entity (including a | |||
cross-claim or counterclaim in a lawsuit) alleging that the Work | |||
or a Contribution incorporated within the Work constitutes direct | |||
or contributory patent infringement, then any patent licenses | |||
granted to You under this License for that Work shall terminate | |||
as of the date such litigation is filed. | |||
4. Redistribution. You may reproduce and distribute copies of the | |||
Work or Derivative Works thereof in any medium, with or without | |||
modifications, and in Source or Object form, provided that You | |||
meet the following conditions: | |||
(a) You must give any other recipients of the Work or | |||
Derivative Works a copy of this License; and | |||
(b) You must cause any modified files to carry prominent notices | |||
stating that You changed the files; and | |||
(c) You must retain, in the Source form of any Derivative Works | |||
that You distribute, all copyright, patent, trademark, and | |||
attribution notices from the Source form of the Work, | |||
excluding those notices that do not pertain to any part of | |||
the Derivative Works; and | |||
(d) If the Work includes a "NOTICE" text file as part of its | |||
distribution, then any Derivative Works that You distribute must | |||
include a readable copy of the attribution notices contained | |||
within such NOTICE file, excluding those notices that do not | |||
pertain to any part of the Derivative Works, in at least one | |||
of the following places: within a NOTICE text file distributed | |||
as part of the Derivative Works; within the Source form or | |||
documentation, if provided along with the Derivative Works; or, | |||
within a display generated by the Derivative Works, if and | |||
wherever such third-party notices normally appear. The contents | |||
of the NOTICE file are for informational purposes only and | |||
do not modify the License. You may add Your own attribution | |||
notices within Derivative Works that You distribute, alongside | |||
or as an addendum to the NOTICE text from the Work, provided | |||
that such additional attribution notices cannot be construed | |||
as modifying the License. | |||
You may add Your own copyright statement to Your modifications and | |||
may provide additional or different license terms and conditions | |||
for use, reproduction, or distribution of Your modifications, or | |||
for any such Derivative Works as a whole, provided Your use, | |||
reproduction, and distribution of the Work otherwise complies with | |||
the conditions stated in this License. | |||
5. Submission of Contributions. Unless You explicitly state otherwise, | |||
any Contribution intentionally submitted for inclusion in the Work | |||
by You to the Licensor shall be under the terms and conditions of | |||
this License, without any additional terms or conditions. | |||
Notwithstanding the above, nothing herein shall supersede or modify | |||
the terms of any separate license agreement you may have executed | |||
with Licensor regarding such Contributions. | |||
6. Trademarks. This License does not grant permission to use the trade | |||
names, trademarks, service marks, or product names of the Licensor, | |||
except as required for reasonable and customary use in describing the | |||
origin of the Work and reproducing the content of the NOTICE file. | |||
7. Disclaimer of Warranty. Unless required by applicable law or | |||
agreed to in writing, Licensor provides the Work (and each | |||
Contributor provides its Contributions) on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | |||
implied, including, without limitation, any warranties or conditions | |||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | |||
PARTICULAR PURPOSE. You are solely responsible for determining the | |||
appropriateness of using or redistributing the Work and assume any | |||
risks associated with Your exercise of permissions under this License. | |||
8. Limitation of Liability. In no event and under no legal theory, | |||
whether in tort (including negligence), contract, or otherwise, | |||
unless required by applicable law (such as deliberate and grossly | |||
negligent acts) or agreed to in writing, shall any Contributor be | |||
liable to You for damages, including any direct, indirect, special, | |||
incidental, or consequential damages of any character arising as a | |||
result of this License or out of the use or inability to use the | |||
Work (including but not limited to damages for loss of goodwill, | |||
work stoppage, computer failure or malfunction, or any and all | |||
other commercial damages or losses), even if such Contributor | |||
has been advised of the possibility of such damages. | |||
9. Accepting Warranty or Additional Liability. While redistributing | |||
the Work or Derivative Works thereof, You may choose to offer, | |||
and charge a fee for, acceptance of support, warranty, indemnity, | |||
or other liability obligations and/or rights consistent with this | |||
License. However, in accepting such obligations, You may act only | |||
on Your own behalf and on Your sole responsibility, not on behalf | |||
of any other Contributor, and only if You agree to indemnify, | |||
defend, and hold each Contributor harmless for any liability | |||
incurred by, or claims asserted against, such Contributor by reason | |||
of your accepting any such warranty or additional liability. | |||
END OF TERMS AND CONDITIONS | |||
APPENDIX: How to apply the Apache License to your work. | |||
To apply the Apache License to your work, attach the following | |||
boilerplate notice, with the fields enclosed by brackets "[]" | |||
replaced with your own identifying information. (Don't include | |||
the brackets!) The text should be enclosed in the appropriate | |||
comment syntax for the file format. We also recommend that a | |||
file or class name and description of purpose be included on the | |||
same "printed page" as the copyright notice for easier | |||
identification within third-party archives. | |||
Copyright [yyyy] [name of copyright owner] | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
You may obtain a copy of the License at | |||
http://www.apache.org/licenses/LICENSE-2.0 | |||
Unless required by applicable law or agreed to in writing, software | |||
distributed under the License is distributed on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
See the License for the specific language governing permissions and | |||
limitations under the License. |