Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fcasal/cryptoutils.jl
Cryptography and number-theory primitives in Julia
https://github.com/fcasal/cryptoutils.jl
continued-fractions cryptography julia number-theory prime-numbers
Last synced: about 1 month ago
JSON representation
Cryptography and number-theory primitives in Julia
- Host: GitHub
- URL: https://github.com/fcasal/cryptoutils.jl
- Owner: fcasal
- License: mit
- Created: 2019-07-22T00:22:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-07T23:59:56.000Z (over 4 years ago)
- Last Synced: 2024-10-12T23:22:35.892Z (about 1 month ago)
- Topics: continued-fractions, cryptography, julia, number-theory, prime-numbers
- Language: Julia
- Homepage:
- Size: 66.4 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CryptoUtils
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://fcasal.github.io/CryptoUtils.jl/dev/)
## Features
This package supports a number of cryptographic and number theory related primitives:
* generation of random prime numbers and safe primes;
* Jacobi and Legendre symbols;
* modular square roots;
* continued fractions of rationals and convergents;
* "bytes to number" and "number to bytes" conversion functions;
* RSA attacks:
* Wiener's attack with Dujella's extension;
* Factor `n = p*q`, given `e` and `d`.## Installation
To install the package, simply run from the julia REPL:
```
julia> ]add CryptoUtils
```## Documentation
Access the full [documentation](https://fcasal.github.io/CryptoUtils.jl/dev/).## Example
```julia
julia> using CryptoUtilsjulia> p = random_prime(512); q = random_prime(512); n = p*q # generate semiprime n
131745220523048272797760331579564741491214753542423769574982847786514776153155250573474208964071358407384440164414712528658264269591534035958596966591477455650082238340858337257106511821924740760868219278777077341070367621453029038918351903399126114774879588852878367966142856170535138849910785240708139225987julia> e = 65537
65537julia> d = invmod(e, (p-1)*(q-1)) # compute RSA decryption exponent
32362883641310315451899592262377172791965856192371946631485250568611645044625881242387678564972226360689108476233462883544705990145324113781489121643593621753163078450834460663942035227770596133499206721223993086064885467845603112395435294663436699341967664046213003429586468421266641276398515468366056248785julia> factor_with_ed(n, e, d) # factor n with e and d
(11209007052907094316298587866392085453240213973638699831846376613053337678939099626874977325024647359864974367465362518878257931790980202563932031187056729, 11753513928682888932534842071560505691719602160983337271901213762089936749492510218729499032535262339600976674663969869808030961514878135483359095845990203)julia> p
11209007052907094316298587866392085453240213973638699831846376613053337678939099626874977325024647359864974367465362518878257931790980202563932031187056729julia> q
11753513928682888932534842071560505691719602160983337271901213762089936749492510218729499032535262339600976674663969869808030961514878135483359095845990203
```