Is a bitcoin address collision possible if generating 90 million addresses every 4 hours?

I am running a test to see if I can obtain a successful bitcoin address collision after generating billions of addresses. I am not entirely sure how I would check them yet. Basically I have an extra 10TB hard drive and am running supervanitygen on my 32-core, 128gb ram linux work computer. It seems to be generating about 90,000,000 (90 million) addresses (address + private key pair) every 4 hours.

Do you think it’s possible or likely to run into an address collision this way? Or perhaps if everyone in the world did the same thing? Or what if I waited 10-20 years, and then checked the addresses?

This is all just a test to see if the bitcoin system is secure enough for big investment decision.

Generating rotating groups for a seminar

One of my teachers is planning a seminar for his English class and he asked me if there was a way to generate the groups for the days other than brute-force random generating. I really think there should be a way, but I can’t think of something.

Here is the situation:

  • There are 18 kids and 22 days
  • Each seminar has a group of 12 and a group of 6
  • Goals:
    • Maximize the variety of students in groups (i.e. that aren’t always in the same or nearly same group of people)
    • Ensure all students are in both groups about the same amount of times

I was hoping to find a way of solving the problem instead of find just a solution. Basically I have two questions:

  1. Does anyone know how this can be done?
  2. Does anyone have any resources/similar problems/methods that I can look at that might help me solve this?

Generating random 6 digit numbers

We can generate a random 6 digit number $ M$ by first generating a random distribution over the 10 digits and then sampling from that distribution.

Formally, let $ x = (x_0, x_1, x_2, \ldots, x_9)$ be a point sampled from the uniform distribution on the unit sphere in 10 dimensions.

Then $ x$ can be used to define a new RV $ D_x$ on the set $ D = [0, 1, 2, \ldots, 9]$ such that $ P[D_x=i] = {x_i}^2$ .

Now consider the RV $ M_{D_x}$ which is defined by first sampling $ D_x$ 6 times (with replacement) to get a set $ \{s_0, s_1, s_2, \ldots, s_5\}$ and then taking the sum $ \sum_{j = 0}^5 10^j s_j$ (that is, use the 6 numbers generated from $ D_x$ as digits of a number between 0 and 999999).

My question is: what is $ P[M = n]$ for $ n$ between 0 and 999999? Is this a uniform distribution over 6 digit integers?

Complexity of generating non-uniform random variates

What can we say about the complexity of generating (negative) binomial and (negative) hypergeometric random variates? In particular, it is possible to generate (negative) binomial and (negative) hypergeometric variates in (expected) constant time (i.e. independent of the distribution parameters)?

There is quite a bunch of literature; however, it’s hard to understand a lot of the papers. Moreover, I found some statements that seem contradictory to me (probably due to wrong understanding).

For example, Stadlober (or similar here) mentions a “generalization [of the ratio-of-uniforms approach] to any unimodal discrete distribution”. The ratio-of-uniforms approach has been called uniformly fast, which is a synonym for constant time, I suppose (?). That would mean that we can generate random variates for each discrete distribution in (expected) constant time.

However, in another paper, I found the following theorem: On a RAM with word size $ w$ , any algorithm sampling a geometric random variate $ Geo(p)$ with parameter $ p \in (0,1)$ needs at least expected runtime $ \Omega(1 + \log(1/p)/w)$ .

Apparently, this means that it is not possible to generate negative binomial variates in time independent of the distribution parameters.

Generating Image & Serving via HTTP with Go


What is does

I’m reading The Go Programming Language. Below is my code for the last exercise in the first chapter, which is to create a webserver, generate an image, and serve the image via the server, allowing modifications of the image via query string parameters, eg: localhost:8000/?cycles=25&bgcolor=0,255,255.

My Concerns

I’m open to any and all suggestions, but any advice specifically concerning these points would be especially helpful.

Duplicated code. There’s just enough duplication to trigger my OCD, but each one is slightly different so I’m not sure how I could delegate to a function without creating a bunch of very similar functions. In particular, the two for loops where I’m parsing colors really bother me.

Type Juggling. strconv.ParseInt has a third argument to specify the bit size but always returns int64 anyway, so I still have to explicitly cast then to unsigned 8 bit integers. Take a look at my img.SetColorIndex call where I’m doing all sorts of casting just for some simple arithmetic.

Concision. I am baffled at the fact that I can write a simple server using the standard library with about 4 lines of code, but turning a string into an array of numbers took me 19 lines of code. And I had to use basically the same 19 lines twice because I couldn’t figure out what to specify as the type when passing a color.RGBA as a function parameter.

package main  import (     "log"     "net/http"     "io"      "image"     "image/color"     "image/gif"     "math"     "math/rand"      "strconv"     "strings" )  var bgcolor = color.RGBA{0, 0, 0, 255} var fgcolor = color.RGBA{255, 255, 255, 255}  func main() {     http.HandleFunc("/", serveImage)     log.Fatal(http.ListenAndServe("localhost:8000", nil)) }  func serveImage(w http.ResponseWriter, r* http.Request) {     if err := r.ParseForm(); err != nil {         log.Print(err)     }     cycles := 10.0     res := 0.001     size := 100     frames := 64     delay := 8     if value, exists := r.Form["cycles"]; exists {         if v, err := strconv.ParseFloat(value[0], 64); err == nil {             cycles = v         }     }     if value, exists := r.Form["res"]; exists {         if v, err := strconv.ParseFloat(value[0], 64); err == nil {             res = v         }     }     if value, exists := r.Form["size"]; exists {         if v, err := strconv.ParseFloat(value[0], 64); err == nil {             size = int((v-1)/2)         }     }     if value, exists := r.Form["frames"]; exists {         if v, err := strconv.ParseInt(value[0], 10, 0); err == nil {             frames = int(v)         }     }     if value, exists := r.Form["delay"]; exists {         if v, err := strconv.ParseInt(value[0], 10, 0); err == nil {             delay = int(v)         }     }     if value, exists := r.Form["bgcolor"]; exists {         BGColorLoop:              for {                 parts := strings.Split(value[0], ",")                 if len(parts) != 3 {                     break BGColorLoop                 }                 for _, val := range parts {                     if v, err := strconv.ParseInt(val, 10, 0); err != nil || int(v) > 255 || int(v) < 0 {                         break BGColorLoop                     }                 }                 r, _ := strconv.ParseInt(parts[0], 10, 8)                 g, _ := strconv.ParseInt(parts[1], 10, 8)                 b, _ := strconv.ParseInt(parts[2], 10, 8)                 bgcolor = color.RGBA{uint8(r), uint8(g), uint8(b), 255}                 break BGColorLoop             }     }     if value, exists := r.Form["fgcolor"]; exists {         FGColorLoop:              for {                 parts := strings.Split(value[0], ",")                 if len(parts) != 3 {                     break FGColorLoop                 }                 for _, val := range parts {                     if v, err := strconv.ParseInt(val, 10, 0); err != nil || int(v) > 255 || int(v) < 0 {                         break FGColorLoop                     }                 }                 r, _ := strconv.ParseInt(parts[0], 10, 8)                 g, _ := strconv.ParseInt(parts[1], 10, 8)                 b, _ := strconv.ParseInt(parts[2], 10, 8)                 fgcolor = color.RGBA{uint8(r), uint8(g), uint8(b), 255}                 break FGColorLoop             }     }     lissajous(w, cycles, res, size, frames, delay) }  func lissajous(out io.Writer, cycles float64, res float64, size int, nframes int, delay int) {     freq := rand.Float64() * 3.0      anim := gif.GIF{LoopCount: nframes}     phase := 0.0      palette := []color.Color{bgcolor, fgcolor}     for i := 0; i<nframes; i++ {         rect := image.Rect(0, 0, 2*size+1, 2*size+1)         img := image.NewPaletted(rect, palette)         for t:=0.0; t<cycles*2*math.Pi; t+=res {             x := math.Sin(t)             y := math.Sin(t*freq+phase)             img.SetColorIndex(size+int(x*float64(size)+0.5), size+int(y*float64(size)+0.5), 1)         }         phase += 0.1         anim.Delay = append(anim.Delay, delay)         anim.Image = append(anim.Image, img)     }     gif.EncodeAll(out, &anim) } 

Generating a custom wordlist with a specific mask

I have tried this in Crunch and maskprocessor but neither seem to have the ability to do what I want

I want to generate all possible combinations of the below string:

AA-****-**

Where –

“AA” = literal characters (ie every string starts with AA)

“-” = literal character again (must be in this position in every generated string)

“*” = variable – can be an uppercase alphabet character OR a number 0-9

Crunch can do everything except the “or” I have to specify either alpha or number.

thanks

decorator pattern for generating complete html

I am trying to figure out the best way to decorate html. What I mean is replacing specific syntax string with the actual content.

Kind of like, razor syntax in Asp.net MVC using <%= %>.

Currently, I have an HTML page with design and I just need to replace tags (for ex: <%HISTORICTABLE%>) with actual content.

I have 5-6 tags in HTML that needs to be replaced with the original html.

I might add new/remove tags (‘behaviour’) from html.

I think decorator pattern should do the trick or would you think its an overkill?

Generating Random Values for Primitive Types

This is my first code review question in here, so kindly guide me if I need to format the question in a better way.

Task Description

Aim of the task is to create a set of methods that would allow me to create random values for given primitive type. This would be used later in a method that would reflect on a Complex Type (Class/Struct) and assign random values to each of the members (Nested Properties are also taken care of in the other method).

The code attached set of methods for creating Random Values. I was wondering if this is the best way to create a Random Value for each of the primitive type.

Code

    private static bool RandomBoolean()     {         return Convert.ToBoolean(random.Next(0, 2));      }     private static double RandomDouble(Int32 minValue=Int32.MinValue,Int32 maxValue= Int32.MaxValue)     {         return random.NextDouble() * (double)random.Next(minValue,maxValue);     }      private static char RandomChar(bool isLowerCase = true)     {         if (isLowerCase)             return  (char)random.Next((int)'a', (int)'z');          else             return (char)random.Next((int)'A', (int)'A');     }     private static byte RandomByte()     {         var byteArray = new byte[1];         random.NextBytes(byteArray);         return byteArray[0];     }      private static sbyte RandomSByte(int minValue=sbyte.MinValue, int maxValue = sbyte.MaxValue)     {         return (sbyte)random.Next(minValue, maxValue);     }      private static float RandomFloat()     {         double mantissa = (random.NextDouble() * 2.0) - 1.0;         double exponent = Math.Pow(2.0, random.Next(-126, 128));         return (float)(mantissa * exponent);     }       private static decimal RandomDecimal()     {         byte scale = (byte)random.Next(29);         bool sign = random.Next(2) == 1;         return new decimal(random.NextInt32(),                            random.NextInt32(),                            random.NextInt32(),                            sign,                            scale);     }      private static short RandomInt16(int minValue = Int16.MinValue, int maxValue = Int16.MaxValue)     {         return (short)random.Next(minValue, maxValue);     }      private static int RandomInt32(int minValue = Int32.MinValue, int maxValue = Int32.MaxValue)     {         return random.Next(minValue, maxValue);     }      private static long RandomInt64(long minValue = Int32.MinValue, long maxValue = Int32.MaxValue)     {         long result = random.Next((Int32)(minValue >> 32), (Int32)(maxValue >> 32));         result = (result << 32);         result = result | (long)random.Next((Int32)minValue, (Int32)maxValue);         return result;     }       private static UInt16 RandomUInt16()     {         var byteArray = new byte[2];         random.NextBytes(byteArray);         return BitConverter.ToUInt16(byteArray, 0);     }      private static UInt32 RandomUInt32()     {         var byteArray = new byte[4];         random.NextBytes(byteArray);         return BitConverter.ToUInt32(byteArray,0);     }      private static UInt64 RandomUInt64()     {         var byteArray = new byte[8];         random.NextBytes(byteArray);         return BitConverter.ToUInt64(byteArray, 0);     }      private static string RandomString(int length = 10)     {         const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";         return new string(Enumerable.Repeat(chars, length)           .Select(s => s[random.Next(s.Length)]).ToArray());     } 

PS : Kindly note that each of the methods are private and static by intention. I have a extension method GetRandomValues(this Type source) defined in the same class which has a return type dynamic.