-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 81f9cfa
Showing
350 changed files
with
63,246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/build/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
*.log | ||
*.gz | ||
*.tmp | ||
/.mvn/wrapper/maven-wrapper.jar | ||
/.mvn/wrapper/maven-wrapper.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM openjdk:8-jdk-alpine | ||
VOLUME /tmp | ||
EXPOSE 8081 | ||
ADD target/*.jar app.jar | ||
ADD docker-files/beacon.cer beacon.cer | ||
ADD docker-files/beacon-priv.pem beacon-priv.pem | ||
ENV JAVA_OPTS="" | ||
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 leandrofpk | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# Inmetro Randomness Beacon | ||
|
||
<!--Inmetro Beacon Engine é uma implementação do protocolo [NISTIR 8213]() do NIST. Este projeto faz parte do Programa | ||
de [Mestrado em Tecnologia e Qualidade](http://www.inmetro.gov.br/ensino_e_pesquisa/mpmq/index.asp) do [Inmetro](https://www4.inmetro.gov.br/). | ||
O serviço pode ser encontrado aqui: https://beacon.inmetro.gov.br/ | ||
--> | ||
|
||
O beacon do inmetro é uma implementação do protocolo NISTIR 8213 | ||
[(KELSEY et al., 2019)](https://csrc.nist.gov/projects/interoperable-randomness-beacons). <!-- com algumas particularidades.--> | ||
A poposta deste trabalho é uma arquitetura flexível para uso interno no [Inmetro](https://www4.inmetro.gov.br/), mas que também possa ser adotada por outros laboratórios. O | ||
objetivo é propor um processo conceitual onde cada etapa tem suas responsabilidades bem definidas onde uma configuração inicial padrão é fornecida com custo zero de configuração, | ||
mas que permita pontos de configuração e pontos de extensão que serão detalhados mais a frente. | ||
|
||
## Definição de Beacon | ||
|
||
De maneira resumida, o modelo de operação do protocolo NISTR funciona da segunde forma. Primeiro, a cada minuto, 512 bits de entropia são gerados e um registro | ||
único de tempo é adicionado. Segundo, todos os números recebidos no mesmo timestamp são combinados (um hash de todos os valores concatenados) e os demais campos do | ||
protocolo são calculados para formar uma cadeia. Terceiro, o novo pulso é assinado e armazenado no banco de dados. Neste momento o pulso já se torna disponível para | ||
utilização. | ||
|
||
Segundo [(BONNEAU; CLARK; GOLDFEDER, 2015;](https://eprint.iacr.org/2015/1015)[CopenhagenInterpretation)](http://www.copenhagen-interpretation.com/home/cryptography/cryptographic-beacons), beacons devem atender as seguintes características: | ||
|
||
* **Imprevisível:** Nenhum adversário pode ser capaz de prever qualquer informação sobre o número até que ele se torne público; | ||
* **Imparcial:** Um pulso deve ser estatisticamente próximo a uma sequência aleatória uniforme; | ||
* **Amostragem universal:** após a publicação, qualquer parte tem acesso irrestrito a ele; | ||
* **Universalmente verificável:** Pode ser verificável por qualquer usuário após a publicação. | ||
|
||
## Modules | ||
|
||
O inmetro beacon é composto por vários múdulos, são eles: | ||
|
||
* [Beacon Input](https://github.com/leandrofpk/beacon-input): Processo de aquisição da entropia; | ||
* [Beacon Engine](https://github.com/leandrofpk/beacon-engine): Implementação do protocolo NISTIR. Os novos pulsos são gerados neste processo; | ||
* [Beacon Interface](https://github.com/leandrofpk/beacon-interface): Responsável pela publicação externa de todos os pulsos gerados; | ||
* [Beacon libs](https://github.com/leandrofpk/beacon-libs): Bibliotecas são compartilhadas entre os projetos. | ||
|
||
<!-- | ||
## Beacon Engine | ||
Uma descrição... | ||
--> | ||
|
||
|
||
## Built With | ||
|
||
* Java 8+ - Programming language | ||
* [Spring](https://spring.io/) - The web framework used | ||
* [Maven](https://maven.apache.org/) - Dependency Management | ||
* Mysql | ||
* [RabbitMQ](https://www.rabbitmq.com/): Fila de mensagens utilizadas para integrar os módulos | ||
|
||
## Installation and Getting Started | ||
|
||
A maneira mais fácil de executar a solução é executar via docker container. | ||
|
||
``` | ||
1. git clone https://github.com/leandrofpk/beacon-engine.git | ||
2. cd beacon-engine | ||
3. docker-compose up | ||
4. Apontar o navegador web para http://localhost:8080 | ||
``` | ||
|
||
Todas as imagens docker podem ser encontadas aqui: https://hub.docker.com/u/lpcorrea | ||
|
||
## Building from Source | ||
|
||
1. Criar uma pasta para o projeto (Ex.: beacon) e clonar os repositórios dentro da nova pasta(input, engine, interface e libs). | ||
Ao final, as pastas devem ter o seguinte formato: | ||
``` | ||
beacon | ||
├── beacon-engine | ||
├── beacon-input | ||
├── beacon-interface | ||
└── beacon-libs | ||
``` | ||
|
||
2. Instalar as libs compartilhadas | ||
|
||
``` | ||
cd beacon\beacon-libs | ||
mvn clean install | ||
``` | ||
|
||
3. Executar ou compilar os projetos | ||
|
||
```` | ||
cd /beacon/<projeto>/ | ||
Executar: mvn spring-boot:run | ||
Compilar: nvn clean package -DskipTests | ||
```` | ||
|
||
4 Criar dois bancos de dados no mysql: | ||
``` | ||
Bancos: beacon-input e beacon2 | ||
Usuario: root e senha 123456 | ||
```` | ||
5. Instalar a fila de mensagens RabbitMq e importar as configurações da | ||
rquivo [definitions.json](https://github.com/leandrofpk/beacon-engine/blob/master/docker-files/definitions.json). A | ||
interface de administração possui uma funcionalidade para importação. | ||
<!--https://gist.github.com/lucianfialhobp/14326023cb7f661eaf80 --> | ||
## Arquitetura da solução | ||
 | ||
## Como o beacon funciona? | ||
<!-- Página 62 - Design da solução --> | ||
O processo de geração de um pulso se inicia no microserviço entrada, passa pela fila, pelo microserviço motor até que finalmente o novo pulso é exposto externamente por intermédio do microserviço interface. É importante lembrar que todos os eventos | ||
acontecem regularmente em tempos definidos. Exemplo, a geração do pulso ocorre uma vez a cada minuto exatamente no segundo 51. A seguir, as responsabilidades de cada conteiner apresentado na figura acima serão detalhados obedecendo a ordem cronológica dos eventos. | ||
1. **Microserviço entrada:** Envio regular **(segundo 50.** Ex.: 10:00:50, 10:01:50...) | ||
1. Recupera os dados da entropia; | ||
2. Adiciona um timeStamp; | ||
3. Armazena em banco de dados local; | ||
4. Envia para a fila. | ||
2. **Microserviço entrada:** Reenvio **(segundo 51)** | ||
1. Tentativa de reenvio de todos os pulsos que tiveram problemas no envio regular. | ||
3. **Fila de mensagens:** Armazena os pulsos na ordem de chegada. | ||
1. Os registros são mantidos na fila até serem lidos pelo motor; | ||
2. Após a confirmação de leitura, os registros são apagados automaticamente; | ||
4. **Microserviço motor (segundo 00)** | ||
1. Recupera todos os valores da fila; | ||
2. Ordena por timeStamp, realiza a combinação das diversas fontes de entropia, realiza o encadeamento dos pulsos, assina digitalmente e armazena no banco de dados. | ||
5. **Microserviço interface** | ||
1. Permite que todos os números sejam acessados assim que forem gravados no banco de dados; | ||
2. É executado sob demanda. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
version: '3.7' | ||
services: | ||
rabbitmq: | ||
image: rabbitmq:3.8.2-management | ||
ports: | ||
- "5672:5672" | ||
- "15672:15672" | ||
restart: always | ||
volumes: | ||
- ${DATA_PATH_HOST}/rabbitmq:/var/lib/rabbitmq/mnesia:rw | ||
- ./docker-files/definitions.json:/opt/definitions.json:ro | ||
- ./docker-files/rabbitmq.config:/etc/rabbitmq/rabbitmq.config:ro | ||
networks: | ||
- beacon-network | ||
|
||
mysql-beacon-db: | ||
image: mysql:5.7 | ||
ports: | ||
- "3306:3306" | ||
restart: always | ||
environment: | ||
MYSQL_ROOT_PASSWORD: ZT9HHR953OJRFANH | ||
MYSQL_DATABASE: beacon_input | ||
volumes: | ||
- mysql-beacon-data-volume:/var/lib/mysql | ||
- ./docker-files/provision/mysql/init:/docker-entrypoint-initdb.d | ||
networks: | ||
- beacon-network | ||
|
||
beacon-input: | ||
image: lpcorrea/beacon-input:1.0.1.RELEASE | ||
ports: | ||
- "8091:8091" | ||
restart: always | ||
depends_on: # Start the depends_on first | ||
- mysql-beacon-db | ||
environment: | ||
SPRING_PROFILES_ACTIVE: default | ||
RDS_HOSTNAME: mysql-beacon-db | ||
RDS_PORT: 3306 | ||
RDS_DB_NAME: beacon_input | ||
RDS_USERNAME: root | ||
RDS_PASSWORD: ZT9HHR953OJRFANH | ||
RABBIT_URI: amqp://guest:guest@rabbitmq:5672 | ||
BEACON_RABBIT_HOSTNAME: rabbitmq | ||
depends_on: | ||
- rabbitmq | ||
- mysql-beacon-db | ||
networks: | ||
- beacon-network | ||
|
||
beacon-engine: | ||
image: lpcorrea/beacon-engine:1.0.3.RELEASE | ||
ports: | ||
- "8081:8081" | ||
restart: always | ||
environment: | ||
RDS_HOSTNAME: mysql-beacon-db | ||
RDS_PORT: 3306 | ||
RDS_DB_NAME: beacon2 | ||
RDS_USERNAME: root | ||
RDS_PASSWORD: ZT9HHR953OJRFANH | ||
RABBIT_URI: amqp://guest:guest@rabbitmq:5672 | ||
BEACON_RABBIT_HOSTNAME: rabbitmq | ||
BEACON_NUMBER_OF_ENTROPY_SOURCES: 1 | ||
BEACON_MAIL_TEST_CONNECTION: "false" | ||
BEACON_SEND_ALERTS_BY_EMAIL: "false" | ||
BEACON_X509_CERTIFICATE: beacon.cer | ||
BEACON_X509_PRIVATEKEY: beacon-priv.pem | ||
BEACON_ENGINE_LOG_LEVEL: warn | ||
depends_on: # Start the depends_on first | ||
- rabbitmq | ||
- mysql-beacon-db | ||
networks: | ||
- beacon-network | ||
|
||
beacon-interface: | ||
image: lpcorrea/beacon-interface:1.0.0.RELEASE | ||
ports: | ||
- "8080:8080" | ||
restart: always | ||
environment: | ||
RDS_HOSTNAME: mysql-beacon-db | ||
RDS_PORT: 3306 | ||
RDS_DB_NAME: beacon2 | ||
RDS_USERNAME: root | ||
RDS_PASSWORD: ZT9HHR953OJRFANH | ||
RABBIT_URI: amqp://guest:guest@rabbitmq:5672 | ||
BEACON_RABBIT_HOSTNAME: rabbitmq | ||
BEACON_X509_CERTIFICATE: beacon.cer | ||
BEACON_X509_PRIVATEKEY: beacon-priv.pem | ||
BEACON_ENGINE_LOG_LEVEL: warn | ||
depends_on: # Start the depends_on first | ||
- beacon-engine | ||
networks: | ||
- beacon-network | ||
|
||
volumes: | ||
mysql-beacon-data-volume: | ||
|
||
# Networks to be created to facilitate communication between containers | ||
networks: | ||
beacon-network: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIJJwIBAAKCAgEAtkgtb6B05KPqd3QdCbudT216G1g26K2inBIXyVkKNnB0lWgr | ||
74NhJ03D32NWKZ70Ceh0PBHpUV7uYGCEO+TGaEV/yn01suHrfzT7CT9Dbxz5gikd | ||
DuZgkYGGN/8LdYcPv1iP63LnBobgAmQozWd2NZwhSuGgQEYMHCp4pOXfSRaQmZ1v | ||
MkASvGgW+NsFx3QGd7GYmPKuzRnWhRXzWG/qeJ7/3+Ek6q8K4FEjSz/etSRYBHkS | ||
38UTLNol8sV3kyDPh+oTFzgzBbQQ4SWe/8z6Ym53CauRLuFekPjwea6f8iMefH1E | ||
nKMaKEx+P4iK+DjNEoQCb/oxzHXs/XFpCuoK37O8Z7CeqnbO89UOcn+Ml/NqEW1N | ||
t6Wdbg7v0GeClWW21c7dc2X0EOoEfiPlHemScQQouqsFIMeLGiPmmKH+zwUDr98d | ||
87Dw54a+uQGWZHsN5+N2epjstjNrbB+hpqz02VG4QcGTLqyct5ldhPkGDo0pdmhk |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w/0nNwaZKKzf9WgK | ||
zrnCFemZFYG9oB6jfqOoNJbHXEvFjSPIUiXGErNfufSUA0QvKu4Jh4RQIhIPCb7U | ||
8pGeepPEhF/Go6yu68xQuupqKBB5iOLhonugfpmMuYmSaaWmIj+MqYdqaGFuM02a | ||
cxelnwML13UJslVn0Q0jrjgu7tVcnErY3uBpaqeZP10jXTk7VzyJoczK8oAUbSQT | ||
UZBFha3I/PpRlELiOmEmjDDf3bZgAIECggEABRChshpAL53uqnd5jMtkNPD0CE67 | ||
FVxxBbDMDZP9Gz179+Re4usrrsAr3rCTV9GJj+WSrBPTMNqv8VzmCJN/3QUDg97X | ||
pKjh/4kJq4Oupwgh41/xKMJ0S4cDXYZhpv8BWkIdey1yjMXy8c51bcxpGOHuoUfJ | ||
keuoMnmlxMW+YgG3VCltCVQpYaHRH8xr96qKbKFBHT/ob8YUXquITMpg+2N9/TBH | ||
FOCvOkGWWk+uH2Wo3kvAL3AVYEh3+fknB2yALCjHpJebtaRqJCR5HFUroQqLYi5z | ||
ASvziQj2j9JIbZtmS1lZ06+p3evM2Eu/CdqkDGmQIuhh6LYRSNRzZJoqjw== | ||
-----END RSA PRIVATE KEY----- |
Oops, something went wrong.