Skip to content

Commit

Permalink
move to monero builders
Browse files Browse the repository at this point in the history
  • Loading branch information
detherminal committed Apr 12, 2024
1 parent 52a3b5a commit c05cf71
Show file tree
Hide file tree
Showing 37 changed files with 146 additions and 86 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023-2024, Monume (monume.xyz)
Copyright (c) 2023-2024, Monero Builders (monero.builders)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
[![Crates.io](https://img.shields.io/crates/v/libmonero.svg)](https://crates.io/crates/libmonero)
[![Docs](https://docs.rs/libmonero/badge.svg)](https://docs.rs/libmonero)
![License](https://img.shields.io/badge/license-MIT-blue.svg)
[![Dependency Status](https://deps.rs/repo/github/monumexyz/libmonero/status.svg)](https://deps.rs/repo/github/monumexyz/libmonero)
[![Matrix](https://img.shields.io/badge/Matrix-Monume-white?logo=matrix&labelColor=grey&logoColor=white)](https://matrix.to/#/#monume:matrix.org)
[![Dependency Status](https://deps.rs/repo/github/monerobuilders/libmonero/status.svg)](https://deps.rs/repo/github/monerobuilders/libmonero)

> DISCLAIMER: This library is still in early development and doesn't have a stable version yet. It is not ready for production use and not cryptographically audited. We are working hard to make it as secure as possible. Please use it at your own risk.
Expand All @@ -33,14 +32,7 @@ Add the library to your project and use the functions: \
```cargo add libmonero```

For more details, please take a look at [docs](https://docs.rs/libmonero).
If you have any questions, you can ask either at the [discussions](https://github.com/monumexyz/libmonero/discussions) or [matrix channel](https://matrix.to/#/#monume:matrix.org).

## Supporting

As you may notice, we don't make any money from this project. We are working on this project for the Monero community and for the love of open-source. If you want to support us, you can donate to the following Monero address:
```
42monume4tTXqMHPDAQ3wSgUo1oN3kT9hKytkyEGYKP8g3DAWoLk2hUJ2SiwNyvC93cq3wb7VgEe7CZ4NH4dzemWFD1xd5ye
```
If you have any questions, you can ask it at the [discussions](https://github.com/monerobuilders/libmonero/discussions).

## Licensing

Expand All @@ -60,6 +52,6 @@ Almost every Monero 'library' on the net is either a wrapper or a port of the of

¹: This library is written from scratch in Rust and is designed to be easy to use and understand with no need for any other software (other than Monero Daemon for blockchain data etc., NO WALLET RPC). We aim for this library to be usable even for embedded apps. That's why we are calling it 'batteries-included'.

Building this library from scratch is a huge task. We are working hard to make it as good as possible. If you want to help us, please consider contributing to this project. We are looking for people who can help us with the development, testing, and documentation. If you are interested and need any help about it, please contact community at the matrix room: [#monume:matrix.org](https://matrix.to/#/#monume:matrix.org)
Building this library from scratch is a huge task. We are working hard to make it as good as possible. If you want to help us, please consider contributing to this project. We are looking for people who can help us with the development, testing, and documentation.

TL;DR: No-bullshit, standalone, fast, safe and easy to use library for Monero did not exist, so we made one.
2 changes: 1 addition & 1 deletion precommit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ echo ""
echo "STARTING: Running precommit checks"
echo ""
# First step, run copyright script, update the output as the status
printf "1 - status: running - process: running copyright" && python3 scripts/copyright.py && printf "\r1 - status: success - process: running copyright\n"
printf "1 - status: running - process: running copyright" && cd scripts && python3 copyright.py && cd .. && printf "\r1 - status: success - process: running copyright\n"
# Second step, run clippy
printf "2 - status: running - process: running clippy" && cargo clippy -q --all-targets --all-features -- -D warnings && printf "\r2 - status: success - process: running clippy\n"
# Third step, run test with no output, check if process exited with 0
Expand Down
4 changes: 2 additions & 2 deletions scripts/copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# To update the header, only change the variable below and run the script

header = """/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/block.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/nodes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/rpcs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/transactions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/crypt/cryptonight/aesu.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/crypt/cryptonight/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/crypt/cryptonight/otheru.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/crypt/cryptonight/slow_hash.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/crypt/ed25519.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/crypt/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
70 changes: 59 additions & 11 deletions src/keys/keys.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand All @@ -14,13 +14,12 @@

use crate::crypt::ed25519::sc_reduce32;
use crate::mnemonics::original::wordsets::{WordsetOriginal, WORDSETSORIGINAL};
use crate::mnemonics::polyseed::wordsets::WORDSETSPOLYSEED;
use crc32fast::Hasher;
use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, EdwardsPoint, Scalar};
use rand::Rng;
use sha3::{Digest, Keccak256};
use core::panic;
use std::ops::Mul;
use std::time::{SystemTime, UNIX_EPOCH};
use std::vec;

/// Returns cryptographically secure random element of the given array
Expand Down Expand Up @@ -107,8 +106,48 @@ fn generate_mymonero_seed(language: &str) -> Vec<&str> {
seed
}

fn print_seed_pretty(seed: Vec<Vec<bool>>) {
for word in seed.iter() {
for bit in word.iter() {
print!("{}", if *bit { "1" } else { "0" });
}
println!();
}
}

static POLYSEED_MUL2_TABLE: [u16; 8] = [5, 7, 1, 3, 13, 15, 9, 11];

fn gf_elem_mul2(x: u16) -> u16 {
if x < 1024 {
return 2 * x;
}
POLYSEED_MUL2_TABLE[x as usize % 8] + 16 * ((x - 1024) / 8)
}

fn gf_poly_eval(coeff: &[u16; 16]) -> u16 {
// Horner's method at x = 2
let mut result = coeff[15];
for i in (0..15).rev() {
result = gf_elem_mul2(result) ^ coeff[i];
}
result
}

/*
/// Generates a cryptographically secure 2048-type (16-word) seed for given language
fn generate_polyseed_seed(language: &str) -> Vec<&str> {
// Encoding
// Each word contains 11 bits of information. The data are encoded as follows:
// word # contents
// 1 checksum (11 bits)
// 2-6 secret seed (10 bits) + features (1 bit)
// 7-16 secret seed (10 bits) + birthday (1 bit)
// In total, there are 11 bits for the checksum, 150 bits for the secret seed, 5 feature bits and 10 birthday bits. Because the feature and birthday bits are non-random, they are spread over the 15 data words so that two different mnemonic phrases are unlikely to have the same word in the same position.
// Checksum
// The mnemonic phrase can be treated as a polynomial over GF(2048), which enables the use of an efficient Reed-Solomon error correction code with one check word. All single-word errors can be detected and all single-word erasures can be corrected without false positives.
// Check if language is supported
if !WORDSETSPOLYSEED.iter().any(|x| x.name == language) {
panic!("Language not found");
Expand All @@ -133,9 +172,7 @@ fn generate_polyseed_seed(language: &str) -> Vec<&str> {
birthday_bits.drain(..6);
let seed_bits = get_random_bits(150); // Get 150 random bits
let features_bits = [false; 5]; // We don't use any feature while generating the seed
let mut words_bits: Vec<Vec<bool>> = Vec::with_capacity(16); // The seed of Polyseed is 16 words long
// Add checksum bits to the seed
words_bits.push(vec![false; 11]);
let mut words_bits: Vec<Vec<bool>> = Vec::with_capacity(15); // 16 minus 1 checksum word
// Add secret seed and features bits
for (index, item) in features_bits.iter().enumerate() {
let mut word: Vec<bool> = Vec::with_capacity(11);
Expand All @@ -161,19 +198,30 @@ fn generate_polyseed_seed(language: &str) -> Vec<&str> {
words_bits.push(word);
}
// Choose words based on each bits, corresponding to 0-2047
let mut seed: Vec<&str> = Vec::new();
for word_bits in words_bits {
let mut words_indexes: [u16; 16] = [0; 16];
for (index, word_bits) in words_bits.iter().enumerate() {
let mut word_index: u16 = 0;
for (i, bit) in word_bits.iter().enumerate() {
if *bit {
word_index += 2u16.pow((10 - i) as u32);
}
}
seed.push(WORDSETSPOLYSEED[0].words[word_index as usize]);
words_indexes[index] = word_index;
}
print_seed_pretty(words_bits);
// Calculate checksum based on comment describing
let checksum = gf_poly_eval(&words_indexes);
// Add checksum word
let mut seed: Vec<&str> = Vec::new();
seed.push(WORDSETSPOLYSEED[0].words[checksum as usize]);
// Add rest of the words
for index in 0..15 {
seed.push(WORDSETSPOLYSEED[0].words[words_indexes[index] as usize]);
}
// Finally, return the seed
seed
}
*/

/// Generates a cryptographically secure mnemonic phrase for given language and seed type
///
Expand Down Expand Up @@ -204,7 +252,7 @@ pub fn generate_seed(language: &str, seed_type: &str) -> Vec<String> {
let seed = match seed_type {
"original" => generate_original_seed(language),
"mymonero" => generate_mymonero_seed(language),
"polyseed" => generate_polyseed_seed(language),
"polyseed" => panic!("Polyseed is not implemented yet"),
_ => panic!("Invalid seed type"),
};
let mut seed_string: Vec<String> = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions src/keys/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/mnemonics/original/languages/chinese_simplified.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/mnemonics/original/languages/dutch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/mnemonics/original/languages/english.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/mnemonics/original/languages/esperanto.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/mnemonics/original/languages/french.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/mnemonics/original/languages/german.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
4 changes: 2 additions & 2 deletions src/mnemonics/original/languages/italian.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Monume's library libmonero
* This file is part of Monero Builders' library libmonero
*
* Copyright (c) 2023-2024, Monume (monume.xyz)
* Copyright (c) 2023-2024, Monero Builders (monero.builders)
* All Rights Reserved
* The code is distributed under MIT license, see LICENSE file for details.
* Generated by Monume
Expand Down
Loading

0 comments on commit c05cf71

Please sign in to comment.