Code Challenge

We want to see how you think, how you write code, and the effort you put into your work.

The following is derived from one of our products, so we're not wasting your time solving a theoretical computer science problem, you're actually doing something directly relevant to what you'll be doing if you join our team.

Using a language of your choice, provide an application that meets the following requirements:
  • Given a string input of up to 250 characters, return a JSON response compliant to the schema defined below.
  • You are responsible for generating a public/private RSA or ECDSA keypair and persisting the keypair on the filesystem
  • Subsequent invocations of your application should read from the same files
  • Document your code, at a minimum defining parameter types and return values for any public methods
  • Include Unit Test(s) with instructions on how a Continuous Integration system can execute your test(s)
  • You may only use first order libraries, you may not use any third party libraries or packages.
  • For example, you may use the OpenSSL library, but you may not use any libraries built on top of OpenSSL.

JSON Schema for your application response:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Signed Identifier",
  "description": "Schema for a signed identifier",
  "type": "object",
  "required": [ "message", "signature", "pubkey" ],
  "properties": {
      "message": {
          "type": "string",
          "description": "original string provided as the input to your app"
      },
      "signature": {
          "type": "string",
          "description": "RFC 4648 compliant Base64 encoded cryptographic signature of the input, calculated using the private key and the SHA256 digest of the input"
      },
      "pubkey": {
          "type": "string",
          "description": "Base64 encoded string (PEM format) of the public key generated from the private key used to create the digital signature"
      }
    }
}
          

Example:

>./your-awesome-app "your@email.com"

Returns:

{
  "message":"your@email.com",
  "signature":"MGUCMGrxqpS689zQEi5yoBElG41u6U7eKX7ZzaXmXr0C5HgNXlJbiiVQYUS0ZOBxsLU4UgIxAL9AAgkRBUQ7/3EKQag4MjRflAxbfpbGmxb6ar9d4bGZ8FDQkUe6cnCIRleaxFnu2A==",
  "pubkey":"-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEDUlT2XxqQAR3PBjeL2D8pQJdghFyBXWI\n/7RvD8Tsdv1YVFwqkJNEC3lNS4Gp7a19JfcrI/8fabLI+yPZBPZjtvuwRoauvGC6\nwdBrL2nzrZxZL4ZsUVNbWnG4SmqQ1f2k\n-----END PUBLIC KEY-----\n"
}
            

Submission Requirements

  • Provide the JSON output returned from your application using an input value of your email address
  • Provide a Dockerfile in your project. We need to be able to test your code in a consistent manner. Our team uses Docker extensively for continuous integration and service isolation, so it's a great candidate for validating code challenges!
  • Provide a URL or provide a compressed archive of your work

Getting Docker

To use Docker, you will need to download it for your platform of choice:

Docker is also available for other platforms here. Any recent version of Docker is acceptable. Docker community edition is available for free and perfectly acceptable for use in our code challenge.

Golang-Based Submissions

To assist you, we have made an example available for how to package a Golang-based code challenge in a Docker container:

  • Dockerfile - describes the docker image through the use of Dockerfile commands
  • main.go - a simple Go program for use with the Dockerfile
See Docker official documentation for more information.

Other Languages

If you're not familiar with Golang, that's fine. We accept submissions from any programming language. You will still need to provide a Dockerfile to enable building and running your submission in docker. Not to fear, there are many examples available for other programming langauges:

In general, the procedure will be very similar (the below reference examples from several languages):

  1. Choose a base Docker image that contains your language environment/compiler
    FROM java:8
  2. Add any missing requirements via RUN commands. To install the Java maven tool for dependencies:
    RUN apt-get install maven
  3. Create a workspace to copy your source code to the image:
    RUN mkdir -p $PROJECT_DIR
    WORKDIR $PROJECT_DIR
  4. If your language is compiled, compile the project
    RUN go install $PROJECT_URI
  5. Set the entrypoint so that invoking the built image will call your program
    ENTRYPOINT ["python", "/home/codehallenge/my_app.py"]

Usage

While you can structure your project anyway you want, we recommend you store the Dockerfile at the root of the project directory so that we can find it easily. We will require the following commands to work correctly when we run them in your project directory:
docker build . -t codechal
docker run codechal "your@email.com"
Running the container with the string argument should produce the expected result in standard out. That's it!