stdlib-js / google-summer-of-code

Google Summer of Code resources.
https://github.com/stdlib-js/stdlib
26 stars 7 forks source link

[RFC]: expand support for additional pseudorandom number generators #47

Closed PraneGIT closed 6 months ago

PraneGIT commented 8 months ago

Full name

Pranjal Jha

University status

Yes

University name

IIIT Jabalpur

University program

Computer Science Engineering

Expected graduation

31-5-2025

Short biography

Hey, I am Pranjal Jha, a developer with a passion for backend development and proficiency in JavaScript, coupled with my academic background as a third-year Computer Science student at IIIT Jabalpur, along with internship experience in Android development and proficiency in Node.js,Golang, C, and C++, I believe I am uniquely suited for the project focused on expanding the selection of PRNGs in stdlib.

My diverse skill set spanning across mobile development, backend development, and proficiency in multiple programming languages gives me a holistic understanding of software development. This enables me to approach the project from various angles and ensure compatibility across different platforms and environments. My passion for backend development, demonstrated through my proficiency in Golang and Node.js, drives my interest in projects like expanding the standard library's PRNGs. I understand the importance of robust and efficient random number generation in backend systems, especially in applications requiring numerical simulations or cryptographic operations.

Timezone

India Standard Time

Contact details

email : pranjaljha00@gmail.com

Platform

Linux

Editor

I predominantly use Visual Studio Code (VS Code) as my preferred code editor. Its seamless integration with Ubuntu's ecosystem, along with its extensive range of features and plugins, makes it a versatile and efficient tool for software development. VS Code's intuitive user interface, robust debugging capabilities, and support for various programming languages enhance my productivity and streamline my workflow.

Programming experience

I have experience in competitive programming, on codeforces I am rated about 1300 and use C++ as my primary language. Apart from compitative programming I have made several projects like gRPC – complete which is simple gRPC project that demonstrates unary,client-server,bidirectional communication between a server and a client using Go programming language, while attempting a simple implementation of containerization and creating a pod/deployment. Apart from that I am also experienced in android development, I have also made an expense splitting app ,which helps in split bills and transactions for user with his friends.

JavaScript experience

In JavaScript, I have substantial experience gained through both academic projects and practical applications. I've developed interactive web applications, dynamic user interfaces, and backend services using frameworks like Node.js. I'm proficient in concepts such as asynchronous programming, closures, callbacks, promises, and ES6 features, enabling me to write clean, efficient, and maintainable code. Additionally, I have experience with popular libraries and frameworks like React.js and Express.js

M favorite JS feature is async/await. This feature allows for asynchronous code to be written in a synchronous-like manner, enhancing code readability and maintainability, especially in scenarios where multiple asynchronous operations need to be coordinated or chained together.

I personally do not like the === operator,In many cases, developers prefer strict equality comparisons (===), which require both value and type to be the same for the comparison to evaluate to true.But languages like C++ or even Java handel it much better.

Node.js experience

I have made several personal projects in NodeJS, mostly using the express library for making server side applications using postgres SQL,mySQL,mongoDB as their database. I have also implemented many middlewares in these applications for auth and routing.

C/Fortran experience

In C, I have a solid foundation acquired through coursework, personal projects, and competitive programming. I'm comfortable with low-level programming concepts, memory management, data structures, and algorithm implementation. I've worked on projects ranging from system-level programming to embedded systems development.

Interest in stdlib

stdlib combines the 2 things I really like working on maths and web dev, In stdlib I am thoroughly impressed by the already implementations of Base (i.e., lower-level) pseudorandom number generators (PRNGs). and their implementations. It would be a learning experience for me to implement more of these PRNGs which are not yet implemented in this esteemed organization.

Version control

Yes

Contributions to stdlib

so far in stdlib I have merged 3 pull requests and have 1 unmerged open pull request

detail for merged PRs:

  1. feat: add iter/do-while-each:

adds an iterator utility to invoke a function for each iterated value until a predicate function returns false. This is the iterator equivalent of @stdlib/utils/do-while-each.

2 . feat: add utils/every-own-by:

adds a utility to test whether every "own" property of a provided object satisfies a predicate function. This is the object keys equivalent of @stdlib/utils/every-by.

  1. feat: add iter/sequences/tribonacci:

adding the package @stdlib/math/iter/sequences/tribonacci. The package is similar in structure as @stdlib/math/iter/sequences/fibonacci. Package: @stdlib/math/iter/sequences/tribonacci

Detail for unmerged PR:

  1. refactor: update blas/ext/base/sdssumpw to follow current project conventions:

refactors @stdlib/blas/ext/base/sdssumpw to follow current project conventions. As outlined in Refactor and update existing base BLAS packages according to current project conventions #788.

Goals

Currently, the library offers limited options for PRNGs. This project proposes adding 8 new algorithms (PCG32, Philox, Xorshiro++/Xoshiro**,Arc4Random,ChaCha20 & TinyMT32/64) to provide developers with a wider range of choices depending on their specific needs. The inclusion of a cryptographically secure PRNG like ChaCha20, empowers developers to build more robust security features into their applications, especially those involving sensitive data.

This project has the potential to significantly enhance the @stdlib\random library, providing developers with a broader spectrum of high-performance, statistically sound PRNG

image

All module to be implemented will be similar in structure to @stdlib/random/base/mt19937

providing a comparative analysis of five pseudorandom number generator (PRNG) algorithms: (PCG32, Philox, Xorshiro++/Xoshiro**,Arc4Random,ChaCha20 & TinyMT32/64). Each entry highlights the key strengths and limitations of the respective PRNG, aiding developers in selecting the most suitable option for their specific needs:

1) PCG Family (focusing on PCG32):

Why this project?

Developing high-quality PRNG algorithms requires a deep understanding of mathematical concepts, algorithmic efficiency, and cryptographic principles. As someone passionate about algorithms and cryptography, I am excited about the technical challenges involved in designing and implementing robust PRNGs. As someone with a background in computer science, cryptography, and software development, this project aligns perfectly with my interests and expertise. I bring a combination of theoretical knowledge and practical experience to the table, enabling me to make meaningful contributions to the project.

Qualifications

With experience in JavaScript, C, Kotlin and C++, I have a solid foundation in programming languages commonly used for software development. This enables me to understand and implement algorithms efficiently across different platforms.

As a 3rd year student at IIIT Jabalpur my coursework in computer science , including courses in mathematics and cryptography, has equipped me with a strong mathematical foundation. Understanding the mathematical principles behind PRNG algorithms is crucial for designing and implementing them effectively. Through competitive programming on platforms like Codeforces, I have honed my skills in algorithm design and analysis. This experience allows me to approach the development of PRNG algorithms with a systematic and analytical mindset, ensuring their correctness and efficiency. Courses in advanced cryptography have provided me with insights into cryptographic primitives, randomness requirements, and security considerations.

This knowledge is invaluable for designing PRNGs that meet the stringent requirements of cryptographic applications .As an Android developer with internship experience, I am familiar with software development processes, version control systems, and collaborative tools. I understand the importance of writing clean, maintainable code and adhering to best practices in software engineering.

Prior art

Here is what I found while researching for the project: https://www.pcg-random.org/ https://www.pcg-random.org/pdf/toms-oneill-pcg-family-v1.02.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2075r2.pdf https://www.jstatsoft.org/article/download/v008i14/916 https://xilinx.github.io/Vitis_Libraries/security/2019.2/guide_L1/internals/chacha20.html#:~:text=Chacha20%20is%20a%20cipher%20stream,4*32%2Dbit%20words https://man.openbsd.org/arc4random.3 https://prng.di.unimi.it/

which In my opinion provides enough resources to implement these set of PRNGs in stdlib.

Commitment

1 May - 26 May -> Bonding Period 27 May - 7 July -> 40 hours/week ( 40 6 ) 8 July - 17 August -> 20 hours/week ( 20 6 ) Total = 240 + 120 = 340 hours

Schedule

Assuming a 12 week schedule,

Notes:

Related issues

https://github.com/stdlib-js/stdlib/issues/200 https://github.com/stdlib-js/stdlib/issues/199 https://github.com/stdlib-js/stdlib/issues/201

Checklist

kgryte commented 7 months ago

@PraneGIT A few comments:

  1. In general, we are not concerned with cryptographically secure PRNGs at this point, as we don't (yet) want the burden and responsibility of ensuring cryptographically secure anything.
  2. I think a reasonable target is one new PRNG every week or two, so aiming for 8 PRNGs seems reasonable to me.
  3. Apart from the base implementation, we'll want to add the stream, iter, array, and strided higher level wrappers. Ideally, this will be largely automated, but there may be some initial setup work.
  4. One thing to consider is that we are biased toward 32-bit generators. 64-bit generators are possible, but we'd need to figure out the backward compatibility story, as we support older environments lacking, e.g., BigInt support.

Other PRNGs:

There are likely many more. The main thing is that they be reasonably well-known and permissively licensed. We cannot use anything GNU licensed. So nothing straight from GSL.

PraneGIT commented 7 months ago

@kgryte Thank you for your feedback and suggestions regarding the proposed project. I appreciate the opportunity to refine the proposal based on the project's requirements and priorities. Upon further research I have decided to work on these PRNGs, I have added Xoshiro++/** as I believe they are more useful and popular 32-bit generators.

Also I have added TinyMT32/64 in my proposal. Now I have a total of 8 PRNGs to implement this summer. I will add the stream, iter, array, and strided higher level wrappers within the 1st week of my project and will ensure that all selected PRNGs adhere to permissive licenses and are compatible with the project's licensing requirements. This includes avoiding PRNGs licensed under GNU licenses.

please have a review of updated issue.

kgryte commented 7 months ago

Thanks for the updates.